Fix user test race condition

This commit is contained in:
Ritchie Martori 2014-01-23 14:39:15 -08:00
parent a43d6004c1
commit 86a85291ac
1 changed files with 8 additions and 4 deletions

View File

@ -1,4 +1,4 @@
var User = loopback.User.extend('user');
var User;
var AccessToken = loopback.AccessToken;
var passport = require('passport');
var MailConnector = require('../lib/connectors/mail');
@ -8,10 +8,14 @@ var userMemory = loopback.createDataSource({
});
describe('User', function(){
// allow many User.afterRemote's to be called
User.setMaxListeners(0);
beforeEach(function() {
User = loopback.User.extend('user');
User.email = loopback.Email.extend('email');
loopback.autoAttach();
before(function () {
// allow many User.afterRemote's to be called
User.setMaxListeners(0);
User.hasMany(AccessToken, {as: 'accessTokens', foreignKey: 'userId'});
AccessToken.belongsTo(User);
});