<commit_before>import expect from 'expect';
import chai from 'chai';
import supertest from 'supertest';
import app from '../../config/app';
import db from '../../models';
import groupHelper from '../Helpers/GroupHelper';


const request = supertest(app);
let groupResponse;


describe('Group API', () => {
  describe('create Group', () => {
    beforeEach((done) => {
      request.post('/api/group')
        .send(groupHelper.goodGroup1)
        .end((err, res) => {
          if (err) return err;
          groupResponse = res;
          done();
        });
    });

    afterEach(() => db.Groups.destroy({ where: {} }));

    it('should create a new group', (done) => {
      expect(groupResponse.status).toBe(200);
      expect(groupResponse.body.group).to.have.property(
        'name');
      expect(groupResponse.body.group).to.have.property(
        'description');
      expect(groupResponse.body.message).to.equal(
        'Group successfully created');
      done();
    });


    it('should not create the Group if it already exists', (done) => {
      request.post('/api/group')
        .send(groupHelper.goodGroup1)
        .end((err, response) => {
          if (err) return err;
          expect(response.status).to.equal(409);
          expect(response.body.message).to.equal(
            'Group already exist');
          done();
        });
    });
  });
});<commit_msg>feature: Added test case for group that already exist<commit_after>import chai from 'chai';
import supertest from 'supertest';
import app from '../../config/app';
import db from '../../models';
import groupHelper from '../Helpers/GroupHelper';

const expect = chai.expect;
const request = supertest(app);
const goodGroup = groupHelper.goodGroup;
const badGroup = groupHelper.badGroup;
let newGroupResponse;

describe('POST api/group', () => {
  beforeEach((done) => {
    request.post('/api/group')
    .send(goodGroup)
    .end((err, res) => {
      if (err) return err;
      newGroupResponse = res;
      done();
    });
  });
  afterEach(() => db.Groups.destroy({ where: {} }));
  it('should create a new group', (done) => {
    expect(newGroupResponse.status).to.equal(200);
    expect(newGroupResponse.body).to.have.property('name');
    expect(newGroupResponse.body).to.have.property('description');
    done();
  }); 
  it('should have a createdAt property', (done) => {
    expect(newGroupResponse.body).to.have.property('createdAt');
    done();
  });
  it('should not create group with missing property ', (done) => {
    request.post('/api/group')
    .send(badGroup)
    .end((err, res) => {
      expect(res.body.message).to.equal('property mising');
      return done();
    });
  });
  it('should not create a group if already exist ', (done) => {
    request.post('/api/group')
    .send(goodGroup)
    .end((err, res) => {
      expect(res.status).to.equal(409);
      expect(res.body.message).to.equal('Group already exist');
      return done();
    });
  });
});

{'fraction_non_alphanumeric': 0.17759838546922302, 'fraction_numerical': 0.004709048099562731, 'mean_word_length': 2.887581699346405, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6418086', 'n_tokens_mistral': 894, 'n_tokens_neox': 884, 'n_words': 200}