added some tests, fixed user reset tests

v1.18.x
Julian Lam 10 years ago
parent 66422acea2
commit 04f536854c

@ -195,7 +195,8 @@ describe('User', function() {
});
describe('passwordReset', function() {
var uid;
var uid,
code;
before(function(done) {
User.create({username: 'resetuser', password: '123456', email: 'reset@me.com'}, function(err, newUid) {
assert.ifError(err);
@ -204,11 +205,40 @@ describe('User', function() {
});
});
it('should create a new reset code and reset password', function(done) {
it('.generate() should generate a new reset code', function(done) {
User.reset.generate(uid, function(err, _code) {
assert.ifError(err);
assert(_code);
code = _code;
done();
});
});
it('.validate() should ensure that this new code is valid', function(done) {
User.reset.validate(code, function(err, valid) {
assert.ifError(err);
assert.strictEqual(valid, true);
done();
});
});
it('.validate() should correctly identify an invalid code', function(done) {
User.reset.validate(code + 'abcdef', function(err, valid) {
assert.ifError(err);
assert.strictEqual(valid, false);
done();
});
});
it('.send() should create a new reset code and reset password', function(done) {
User.reset.send('reset@me.com', function(err, code) {
assert.ifError(err);
assert(code);
done();
});
});
it('.commit() should update the user\'s password', function(done) {
User.reset.commit(code, 'newpassword', function(err) {
assert.ifError(err);
@ -223,7 +253,6 @@ describe('User', function() {
});
});
});
});
after(function() {
db.flushdb();

Loading…
Cancel
Save