Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #684 from lirantal/feature/users_tests_email_unique
Browse files Browse the repository at this point in the history
Enhancing users model tests
  • Loading branch information
lirantal committed Jul 24, 2015
2 parents 29d264d + ac35f0f commit a62f25e
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion modules/users/tests/server/user.server.model.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var should = require('should'),
/**
* Globals
*/
var user, user2;
var user, user2, user3;

/**
* Unit tests
Expand All @@ -35,6 +35,15 @@ describe('User Model Unit Tests:', function() {
password: 'password',
provider: 'local'
});
user3 = new User({
firstName: 'Different',
lastName: 'User',
displayName: 'Full Different Name',
email: 'test3@test.com',
username: 'different_username',
password: 'different_password',
provider: 'local'
});

done();
});
Expand Down Expand Up @@ -77,6 +86,37 @@ describe('User Model Unit Tests:', function() {
done();
});
});

it('should be able to save 2 different users', function(done) {
user.remove(function(err) {
should.not.exist(err);
user.save(function(err) {
user3.save(function(err) {
should.not.exist(err);
user3.remove(function(err) {
should.not.exist(err);
done();
});

});
});
});
});

it('should not be able to save different user with the same email address', function(done) {
user.remove(function(err) {
should.not.exist(err);
user.save(function(err) {
user3.email = user.email;
user3.save(function(err) {
should.exist(err);
done();
});
});
});

});

});

after(function(done) {
Expand Down

0 comments on commit a62f25e

Please sign in to comment.