Fix test case error

This commit is contained in:
Loay 2016-07-25 17:22:51 -04:00
parent 8f7e032a01
commit 0fa3327112
1 changed files with 13 additions and 8 deletions

View File

@ -254,19 +254,24 @@ describe('User', function() {
}); });
it('invalidates the user\'s accessToken when the user is deleted all', function(done) { it('invalidates the user\'s accessToken when the user is deleted all', function(done) {
var usersId, accessTokenId; var userIds = [];
var accessTokenId;
async.series([ async.series([
function(next) { function(next) {
User.create([{ name: 'myname', email: 'b@c.com', password: 'bar' }, User.create([
{ name: 'myname', email: 'd@c.com', password: 'bar' }], function(err, user) { { name: 'myname', email: 'b@c.com', password: 'bar' },
usersId = user.id; { name: 'myname', email: 'd@c.com', password: 'bar' },
], function(err, users) {
userIds = users.map(function(u) {
return u.id;
});
next(err); next(err);
}); });
}, },
function(next) { function(next) {
User.login({ email: 'b@c.com', password: 'bar' }, function(err, accessToken) { User.login({ email: 'b@c.com', password: 'bar' }, function(err, accessToken) {
accessTokenId = accessToken.userId; accessTokenId = accessToken.userId;
if (err) return next (err); if (err) return next(err);
assert(accessTokenId); assert(accessTokenId);
next(); next();
}); });
@ -274,7 +279,7 @@ describe('User', function() {
function(next) { function(next) {
User.login({ email: 'd@c.com', password: 'bar' }, function(err, accessToken) { User.login({ email: 'd@c.com', password: 'bar' }, function(err, accessToken) {
accessTokenId = accessToken.userId; accessTokenId = accessToken.userId;
if (err) return next (err); if (err) return next(err);
assert(accessTokenId); assert(accessTokenId);
next(); next();
}); });
@ -286,9 +291,9 @@ describe('User', function() {
}, },
function(next) { function(next) {
User.find({ where: { name: 'myname' }}, function(err, userFound) { User.find({ where: { name: 'myname' }}, function(err, userFound) {
if (err) return next (err); if (err) return next(err);
expect(userFound.length).to.equal(0); expect(userFound.length).to.equal(0);
AccessToken.find({ where: { userId: usersId }}, function(err, tokens) { AccessToken.find({ where: { userId: { inq: userIds }}}, function(err, tokens) {
if (err) return next(err); if (err) return next(err);
expect(tokens.length).to.equal(0); expect(tokens.length).to.equal(0);
next(); next();