thanks a lot for this starter app. In order to understand correctly what you did, I created a blank sails app and copied your User model and user unit test and configured the test with grunt-mocha-test.
When running the test, it seems that beforeCreate is not called (so no encrypedPassword is done). Any idea what can cause this ?
User Model:
Password encryption
for a new user
1) must encrypt the password
for an existing user
if the password was changed
2) must encrypt the new password
if the password was not changed
3) must not try to encrypt the password
Password validation
given a valid password
4) must return true
given an invalid password
5) must return false
Session tokens
#issueSessionToken()
6) must persist a session token in database
#consumeSessionToken()
7) must return the user object and discard the token
API Key
8) must be generateted for a new user
.fullName()
given first name only
✓ must return first name only, no trailing space
given last name only
✓ must return last name only, no preceeding space
given both first and last name
✓ must return the full name
given neither first or last name
✓ must return empty string
.generatePasswordResetToken()
9) "before all" hook
4 passing (887ms)
9 failing
Also, In the User model, you redefined the toJSON method:
toJSON: function() {
var user = this.toObject();
delete user.password;
delete user.passwordConfirmation;
delete user.encryptedPassword;
delete user.sessionTokens;
delete user._csrf;
return user;
},
But there are no password nor passwordConfirmation within the User model.
Hello,
thanks a lot for this starter app. In order to understand correctly what you did, I created a blank sails app and copied your User model and user unit test and configured the test with grunt-mocha-test. When running the test, it seems that beforeCreate is not called (so no encrypedPassword is done). Any idea what can cause this ?
User Model:
4 passing (887ms) 9 failing
Also, In the User model, you redefined the toJSON method:
But there are no password nor passwordConfirmation within the User model.
Any ideas why the unit test does not pass ?