Skip to content

Instantly share code, notes, and snippets.

@tysonnero
Created August 19, 2014 15:30
Show Gist options
  • Save tysonnero/b12b11f089ce5903eb17 to your computer and use it in GitHub Desktop.
Save tysonnero/b12b11f089ce5903eb17 to your computer and use it in GitHub Desktop.
Unit Test for User Model Pre-validate Hook
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