<commit_before>/**
 * Created by lewkoo on 2016-01-27.
 */
'use strict';

/**
 * Module dependencies.
 */

var expect = require('expect.js'),
    mongoose = require('mongoose'),
    User = mongoose.model('User'),
    Course = mongoose.model('Course');

/**
 * Globals
 */
var professor;
var students = [];
var course;

/**
 * Test Suites
 */

var generateRandomStudent = function generateRandomStudent(studentSequenceNumber) {

    return new User({
        name: 'Student ' + studentSequenceNumber,
        email: 'student' + studentSequenceNumber + <EMAIL>',
        username: 'student' + studentSequenceNumber,
        password: '<PASSWORD>'
    });

};

describe('<Unit Test>', function() {
    describe('Model Course:', function() {
        beforeEach(function(done){
            this.timeout(10000);

            professor = new User({
                name: '<NAME>',
                email: '<EMAIL>',
                username: 'number1Prof1972',
                password: '<PASSWORD>'
            });
            professor.save();

            for (var i = 0; i < 5; i++){
                var student = generateRandomStudent(i);
                student.save();
                students.push(student);
            } // generate 5 students


            course = new Course({
               title: 'Test Course',
               description: 'This is a test',
               professor: professor,
               students: students
            });
            done();
        }); // END of beforeEach

        describe('Method Save', function(){

            it('it should be able to save a course without problems', function(done){
                this.timeout(10000);

                return course.save(function(err, data){
                    expect(err).to.be(null);
                    expect(data.title).to.equal('Test Course');
                    expect(data.description).to.equal('This is a test');
                    expect(data.professor.length).to.not.equal(0);
                    expect(data.students.length).to.equal(5);
                    expect(data.created.length).to.not.equal(0);
                    done();
                });
            });

        }); // END of Save method tests


    }); // END of Course model tests
});// END of description of Unit Test Suite<commit_msg>Some initial Courses tests<commit_after>/**
 * Created by lewkoo on 2016-01-27.
 */
'use strict';

/**
 * Module dependencies.
 */

var expect = require('expect.js'),
    mongoose = require('mongoose'),
    User = mongoose.model('User'),
    Course = mongoose.model('Course');

/**
 * Globals
 */
var professor;
var students = [];
var course;

/**
 * Test Suites
 */

var generateRandomStudent = function generateRandomStudent(studentSequenceNumber) {

    return new User({
        name: 'Student ' + studentSequenceNumber,
        email: 'student' + studentSequenceNumber + '@<EMAIL>',
        username: 'student' + studentSequenceNumber,
        password: '<PASSWORD>'
    });

};

describe('<Unit Test>', function() {
    describe('Model Course:', function() {
        beforeEach(function(done){
            this.timeout(10000);

            professor = new User({
                name: 'Some professor',
                email: '<EMAIL>',
                username: 'number1Prof1972',
                password: '<PASSWORD>'
            });
            professor.save();

            for (var i = 0; i < 5; i++){
                var student = generateRandomStudent(i);
                student.save();
                students.push(student);
            } // generate 5 students


            course = new Course({
               title: 'Test Course',
               description: 'This is a test',
               professor: professor,
               students: students
            });
            done();
        }); // END of beforeEach

        describe('Method Save', function(){

            it('it should be able to save a course without problems', function(done){
                this.timeout(10000);

                return course.save(function(err, data){
                    expect(err).to.be(null);
                    expect(data.title).to.equal('Test Course');
                    expect(data.description).to.equal('This is a test');
                    expect(data.professor.length).to.not.equal(0);
                    expect(data.students.length).to.equal(5);
                    expect(data.created.length).to.not.equal(0);
                    done();
                });
            });

            it('it should be throwing an error when course title is not provided', function(done){
                this.timeout(10000);
                course.title = '';

                return course.save(function(err, data){
                    expect(err).to.not.be(null);
                    done();
                });
            });

            it('it should be throwing an error when you try to save a cource without a professor', function(done){
                this.timeout(10000);
                course.professor = null;

                return course.save(function(err, data){
                    expect(err).to.not.be(null);
                    done();
                });
            });



        }); // END of Save method tests

        afterEach(function(done) {
            this.timeout(10000);
            course.remove(function() {
                professor.remove();
                students.forEach(function(entry){
                   entry.remove();
                });
            });
            done();
        });

    }); // END of Course model tests
});// END of description of Unit Test Suite
{'fraction_non_alphanumeric': 0.13056590384956537, 'fraction_numerical': 0.012950150789427, 'mean_word_length': 1.5756052992233898, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 14, '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': '5708001', 'n_tokens_mistral': 1489, 'n_tokens_neox': 1374, 'n_words': 349}