<commit_before>// Load modules

var Lab = require('lab');
var Hapi = require('hapi');

// Test shortcuts

var expect = Lab.expect;
var before = Lab.before;
var beforeEach = Lab.beforeEach;
var after = Lab.after;
var describe = Lab.experiment;
var it = Lab.test;
var S = Hapi.types.String;
var mongoose = require('mongoose');

var Account = require('../../lib/models/Account');

describe('Models', function () {

	var viewsPath = 'templates';
	var routesPath = '../../lib/routes/';

	var options = {
		views: {
			engines: {
				"hbs": "handlebars"
			},
			path: viewsPath,
			layout: true,
			partialsPath: viewsPath + '/partials'
		}
	};

	var dbUri = "mongodb://localhost:27017/mongoose-bcrypt-test-test"

	var correctUser = {
		lastname: 'Test',
		firstname: 'Test',
		nickname: 'tester',
		email: '<EMAIL>',
		password: '<PASSWORD>',
		gender: 'male',
		role: 'student'
	};

	var server = new Hapi.Server(options);

	describe('#user-model', function () {
		before(function (done) {
			mongoose.connect(dbUri, done);
			Account.remove({}, function (err) {
				console.log('BEFORE - Collection Account cleared');
			});
		});
		it('allows creating a new user when all is correct', function (done) {
			var correctUserModel = new Account(correctUser);
			correctUserModel.save(function (err, account) {
				if (err) {
					console.log(err);
				}
				Account.find({_id: account._id}, function (err, foundAccount) {
					if (!err) {
						done();
					} else {
						throw(err);
					}
				});
			});
		});
		it('is able to tell wether a password is correct or not', function (done) {
			Account.findOne({email: '<EMAIL>'}, function (err, foundAccount) {
				foundAccount.comparePassword('<PASSWORD>', function (err, matches) {
					if (err) throw err;<commit_msg>[TASK] Code compactor<commit_after>// Load modules

var Lab = require('lab');
var Hapi = require('hapi');

// Test shortcuts

var expect = Lab.expect;
var before = Lab.before;
var beforeEach = Lab.beforeEach;
var after = Lab.after;
var describe = Lab.experiment;
var it = Lab.test;
var S = Hapi.types.String;
var mongoose = require('mongoose');

var Account = require('../../lib/models/Account');

describe('Models', function () {

	var viewsPath = 'templates';
	var routesPath = '../../lib/routes/';

	var options = {
		views: {
			engines: {
				"hbs": "handlebars"
			},
			path: viewsPath,
			layout: true,
			partialsPath: viewsPath + '/partials'
		}
	};

	var dbUri = "mongodb://localhost:27017/mongoose-bcrypt-test-test"

	var correctUser = {
		lastname: 'Test',
		firstname: 'Test',
		nickname: 'tester',
		email: '<EMAIL>',
		password: '<PASSWORD>',
		gender: 'male',
		role: 'student'
	};

	var server = new Hapi.Server(options);

	describe('#user-model', function () {
		before(function (done) {
			mongoose.connect(dbUri, done);
			Account.remove({}, function (err) {
				console.log('BEFORE - Collection Account cleared');
			});
		});
		it('allows creating a new user when all is correct', function (done) {
			var correctUserModel = new Account(correctUser);
			correctUserModel.save(function (err, account) {
				if (err) throw err;
				Account.find({_id: account._id}, function (err, foundAccount) {
					if (err) throw err;
					if (!err) done();
				});
			});
		});
		it('is able to tell wether a password is correct or not', function (done) {
			Account.findOne({email: '<EMAIL>'}, function (err, foundAccount) {
				foundAccount.comparePassword('test', function (err, matches) {
					if (err) throw err;
{'fraction_non_alphanumeric': 0.16475644699140402, 'fraction_numerical': 0.0028653295128939827, 'mean_word_length': 3.5278858625162126, 'pattern_counts': {'":': 2, '<': 10, '<?xml version=': 0, '>': 10, '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': '469012', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1147, 'n_words': 308}