<commit_before>/**
 * @fileOverview Edit Profile tests.
 */

// var sinon = require('sinon');
var chai = require('chai');
var expect = chai.expect;
// var __ = require('lodash');

var userfix = require('../fixtures/user.fix');
var setupFix = require('../lib/fixtures-user.lib');


describe('Profile Edit', function() {
  this.timeout(10000);

  setupFix.createUser();
  setupFix.login();

  it('should get a redirect to dashboard', function(done) {
    this.req.post('/profile')
      .set('cookie', this.cookie)
      .send({firstName: 'new'})
      .expect(302)
      .expect('location', '/dashboard', done);
  });
  it('should perform the edit', function(done) {
    var self = this;
    this.req.post('/profile')
      .set('cookie', this.cookie)
      .send({firstName: 'new'})
      .expect(302)
      .expect('location', '/dashboard')
      .end(function(err) {
        if (err) { return done(err); }
        self.userEnt.readOne({email: userfix.one.email}).then(function(udo) {
          expect(udo.firstName).to.equal('new');
        }).then(done, done);
      });
  });
  it('should turn verified switch off when email changes ', function(done) {
    var self = this;
    this.req.post('/profile')
      .set('cookie', this.cookie)
      .send({email: '<EMAIL>'})
      .expect(302)
      .expect('location', '/dashboard')
      .end(function(err) {
        if (err) { return done(err); }
        self.userEnt.readOne({_id: self.udo._id}).then(function(udo) {
          expect(udo.email).to.equal('<EMAIL>');
          expect(udo.isVerified).to.be.false;
          expect(udo.emailConfirmation.key).to.not.equal(self.udo.emailConfirmation.key);
        }).then(done, done);
      });
  });
});<commit_msg>amend redirect expectations in profile edit<commit_after>/**
 * @fileOverview Edit Profile tests.
 */

// var sinon = require('sinon');
var chai = require('chai');
var expect = chai.expect;
// var __ = require('lodash');

var userfix = require('../fixtures/user.fix');
var setupFix = require('../lib/fixtures-user.lib');


describe('Profile Edit', function() {
  this.timeout(10000);

  setupFix.createUser();
  setupFix.login();

  it('should get a redirect to ', function(done) {
    this.req.post('/profile')
      .set('cookie', this.cookie)
      .send({firstName: 'new'})
      .expect(302)
      .expect('location', '/', done);
  });
  it('should perform the edit', function(done) {
    var self = this;
    this.req.post('/profile')
      .set('cookie', this.cookie)
      .send({firstName: 'new'})
      .expect(302)
      .expect('location', '/')
      .end(function(err) {
        if (err) { return done(err); }
        self.userEnt.readOne({email: userfix.one.email}).then(function(udo) {
          expect(udo.firstName).to.equal('new');
        }).then(done, done);
      });
  });
  it('should turn verified switch off when email changes ', function(done) {
    var self = this;
    this.req.post('/profile')
      .set('cookie', this.cookie)
      .send({email: '<EMAIL>'})
      .expect(302)
      .expect('location', '/')
      .end(function(err) {
        if (err) { return done(err); }
        self.userEnt.readOne({_id: self.udo._id}).then(function(udo) {
          expect(udo.email).to.equal('<EMAIL>');
          expect(udo.isVerified).to.be.false;
          expect(udo.emailConfirmation.key).to.not.equal(self.udo.emailConfirmation.key);
        }).then(done, done);
      });
  });
});
{'fraction_non_alphanumeric': 0.19567757009345793, 'fraction_numerical': 0.008177570093457943, 'mean_word_length': 2.831096196868009, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '751272', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1103, 'n_words': 205}