<commit_before>const should = require('should');
const dbUtils = require('../dbUtils');
const UserModel = require('../../lib/models/user');
const mongoose = require('mongoose');

describe('User model', function() {

  describe('#create', function() {
    it('should create a new user', function(done) {
      UserModel.create({
        name: {
          given: 'Test',
          family: 'User',
        },
        username: 'tester',
        password: '<PASSWORD>',
        email: '<EMAIL>',
      }, function (err, createdUser) {
        should(err).be.null();
        should(createdUser.name.given).be.equal('Test');
        should(createdUser.name.family).be.equal('User');
        done();
      });
    });
  });

  describe('#pre', function() {
    it('should hash password', function(done) {

      UserModel.findOne({ username: 'tester'}, function(err, doc) {
        should(err).be.null();
        should(doc.password).not.be.equal('<PASSWORD>');
        done();
      });
    });
  });

  describe('#comparePassword', function() {
    it('should compare password', function(done) {

      UserModel.findOne({ username: 'tester'}, function(err, doc) {
        doc.comparePassword('<PASSWORD>', function(err, isMatch) {
          should(err).be.null();
          should(isMatch).be.exactly(true);
          done();
        });
      });
    });
  });
});<commit_msg>test: use new values when testing user model<commit_after>const should = require('should');
const dbUtils = require('../utils/clear-database');
const UserModel = require('../../lib/models/user');
const mongoose = require('mongoose');

describe('User model', function() {

  describe('#create', function() {
    it('should create a new user', function(done) {
      UserModel.create({
        name: {
          given: 'Test',
          family: 'User',
        },
        username: 'usermodel',
        password: '<PASSWORD>',
        email: '<EMAIL>',
      }, function (err, createdUser) {
        should(err).be.null();
        should(createdUser.name.given).be.equal('Test');
        should(createdUser.name.family).be.equal('User');
        done();
      });
    });
  });

  describe('#pre', function() {
    it('should hash password', function(done) {

      UserModel.findOne({ username: 'usermodel'}, function(err, doc) {
        should(err).be.null();
        should(doc.password).not.be.equal('<PASSWORD>');
        done();
      });
    });
  });

  describe('#comparePassword', function() {
    it('should compare password', function(done) {

      UserModel.findOne({ username: 'usermodel'}, function(err, doc) {
        doc.comparePassword('<PASSWORD>', function(err, isMatch) {
          should(err).be.null();
          should(isMatch).be.exactly(true);
          done();
        });
      });
    });
  });
});
{'fraction_non_alphanumeric': 0.19185423365487675, 'fraction_numerical': 0.0, 'mean_word_length': 2.6175710594315245, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4077749', 'n_tokens_mistral': 818, 'n_tokens_neox': 810, 'n_words': 153}