Clean up access-token-invalidation tests

This commit is contained in:
Miroslav Bajtoš 2017-01-13 10:40:48 +01:00
parent dc2b6530b7
commit f8b013dab8
1 changed files with 9 additions and 15 deletions

View File

@ -1989,7 +1989,7 @@ describe('User', function() {
User.login(currentEmailCredentials, function(err, accessToken1) {
if (err) return next(err);
assert(accessToken1.userId);
originalUserToken1 = accessToken1.id;
originalUserToken1 = accessToken1;
next();
});
},
@ -1997,7 +1997,7 @@ describe('User', function() {
User.login(currentEmailCredentials, function(err, accessToken2) {
if (err) return next(err);
assert(accessToken2.userId);
originalUserToken2 = accessToken2.id;
originalUserToken2 = accessToken2;
next();
});
},
@ -2057,7 +2057,7 @@ describe('User', function() {
it('keeps sessions AS IS if firstName is added using `updateAttributes`', function(done) {
user.updateAttributes({'firstName': 'Janny'}, function(err, userInstance) {
if (err) return done(err);
assertUntouchedTokens(done);
assertPreservedTokens(done);
});
});
@ -2068,7 +2068,7 @@ describe('User', function() {
email: currentEmailCredentials.email,
}, function(err, userInstance) {
if (err) return done(err);
assertUntouchedTokens(done);
assertPreservedTokens(done);
});
});
@ -2303,9 +2303,11 @@ describe('User', function() {
function assertPreservedTokens(done) {
AccessToken.find({where: {userId: user.id}}, function(err, tokens) {
if (err) return done(err);
expect(tokens.length).to.equal(2);
expect([tokens[0].id, tokens[1].id]).to.have.members([originalUserToken1,
originalUserToken2]);
var actualIds = tokens.map(function(t) { return t.id; });
actualIds.sort();
var expectedIds = [originalUserToken1.id, originalUserToken2.id];
expectedIds.sort();
expect(actualIds).to.eql(expectedIds);
done();
});
}
@ -2317,14 +2319,6 @@ describe('User', function() {
done();
});
}
function assertUntouchedTokens(done) {
AccessToken.find({where: {userId: user.id}}, function(err, tokens) {
if (err) return done(err);
expect(tokens.length).to.equal(2);
done();
});
}
});
describe('Verification after updating email', function() {