<commit_before>const dbURI = process.env.MONGO_DB_URI;
const should = require('chai').should();
const mongoose = require('mongoose');

var User = require('../../models/user');

describe('User Suite', () => {

  let user;
  beforeEach(() => {
    user = new User();
    user.password = '<PASSWORD>';
  });

  it('should encrypt password', () => {
    expect(user.encryptPassword(user.password)).toContain('$2a$05');
  });

});

describe("Deve testar o Usuario no banco de dados: ", function() {

  beforeEach(function(done) {
    if (mongoose.connection.db) return done();
    mongoose.connect(dbURI, done);
  });

  it("está removendo!", function(done) {
    User.find({
      email: '<EMAIL>'
    }).remove().exec();
    return done();
  });

  it("está salvando!", function(done) {
    const mockedUser = {
      name: '<NAME>',
      city: 'Itaguara',
      state: 'Minas Gerais',
      email: '<EMAIL>',
      password: '<PASSWORD>'
    }

    const newUser = new User(mockedUser);
    newUser.password = newUser.encryptPassword('<PASSWORD>');

    newUser.save(function(err, result) {
      if (err) {
        return done(err);
      }<commit_msg>changing mPromise to globalPromise<commit_after>const dbURI = process.env.MONGO_DB_URI;
const should = require('chai').should();
const mongoose = require('mongoose');

var User = require('../../models/user');

describe('User Suite', () => {

  let user;
  beforeEach(() => {
    user = new User();
    user.password = '<PASSWORD>';
  });

  it('should encrypt password', () => {
    expect(user.encryptPassword(user.password)).toContain('$2a$05');
  });

});

describe("Deve testar o Usuario no banco de dados: ", function() {

  beforeEach(function(done) {
    mongoose.Promise = global.Promise;
    if (mongoose.connection.db) return done();
    mongoose.connect(dbURI, done);
  });

  it("está removendo!", function(done) {
    User.find({
      email: '<EMAIL>'
    }).remove().exec();
    return done();
  });

  it("está salvando!", function(done) {
    const mockedUser = {
      name: '<NAME>',
      city: 'Itaguara',
      state: 'Minas Gerais',
      email: '<EMAIL>',
      password: '<PASSWORD>'
    }

    const newUser = new User(mockedUser);
    newUser.password = newUser.encryptPassword('<PASSWORD>');

    newUser.save(function(err, result) {
      if (err) {
        return done(err);
      }
{'fraction_non_alphanumeric': 0.18358714043993232, 'fraction_numerical': 0.0025380710659898475, 'mean_word_length': 3.245960502692998, 'pattern_counts': {'":': 0, '<': 15, '<?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': '3180158', 'n_tokens_mistral': 793, 'n_tokens_neox': 780, 'n_words': 163}