Created
August 19, 2014 15:30
-
-
Save tysonnero/b12b11f089ce5903eb17 to your computer and use it in GitHub Desktop.
Unit Test for User Model Pre-validate Hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('should validate when password strength passes', function () { | |
var user = new User({ name: 'Test', username: 'Test', password: 'Test@123' }); | |
user.validate(); | |
assert.isUndefined(user.errors); | |
}); | |
it('should invalidate when password strength fails', function () { | |
var user = new User({ name: 'Test', username: 'Test', password: '1234' }); | |
user.validate(); | |
assert.isDefined(user.errors.password); | |
assert.equal(user.errors.password.name, 'ValidatorError'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment