<commit_before><commit_msg>add some server side tests<commit_after>'use strict';

/**
 * Module dependencies.
 */
var should = require('should'),
  mongoose = require('mongoose'),
  User = mongoose.model('User'),
  Group = mongoose.model('Group');

/**
 * Globals
 */
var user;
var group;

/**
 * Test Suites
 */
describe('<Unit Test>', function() {
  describe('Model Group:', function() {
    beforeEach(function(done) {
      user = new User({
        name: '<NAME>',
        email: '<EMAIL>',
        username: 'user',
        password: 'password'
      });

      user.save(function() {
        group = new Group({
          name: 'Group Name',
          description: 'Group Description',
          created_by: user
        });

        done();
      });
    });

    describe('Method Save', function() {
      it('should be able to save without problems', function(done) {
        return group.save(function(err) {
          should.not.exist(err);
          group.name.should.equal('Group Name');
          group.description.should.equal('Group Description');
          group.created_by.should.not.have.length(0);
          group.created.should.not.have.length(0);
          done();
        });
      });

      it('should be able to show an error when try to save without name', function(done) {
        group.name = '';

        return group.save(function(err) {
          should.exist(err);
          done();
        });
      });

      it('should be able to show an error when try to save without description', function(done) {
        group.description = '';

        return group.save(function(err) {
          should.exist(err);
          done();
        });
      });

      it('should be able to show an error when try to save without user', function(done) {
        group.created_by = {};

        return group.save(function(err) {
          should.exist(err);
          done();
        });
      });

    });

    afterEach(function(done) {
      group.remove();
      user.remove();
      done();
    });
  });
});
{'fraction_non_alphanumeric': 0.15403543307086615, 'fraction_numerical': 0.000984251968503937, 'mean_word_length': 2.0525525525525525, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '3517495', 'n_tokens_mistral': 572, 'n_tokens_neox': 566, 'n_words': 137}