I'm trying to run some tests for registering to my app
suite('registering', function() {
var userManager;
setup(function() {
userManager = fixture('UserManager');
return userManager.register();
}); // setup
});
The methods in userManager that i'm using are:
register: function() {
return this._handleRegister().then(function(user) {
return this._updateUserData(user);
});
},
_updateUserData: function(user) {
var updates = {};
var uid = user.uid;
var path = 'users/' + uid + '/';
var meta = {
publicData: false
}
var data = {
name: '',
image: '',
team: '',
email: ''
}
var history = {
createdOn: firebase.database.ServerValue.TIMESTAMP
}
updates[path + 'meta'] = meta;
updates[path + 'data'] = data;
updates[path + 'history'] = history;
return firebase.database().ref().update(updates);
},
_handleRegister: function() {
return this.$.auth.signInAnonymously();
},
This works fine in my application but when executing the test it seems to go into a loop that perpetually increases RAM usage and sets CPU usage to near 100%
_handleRegister
returns Promise non-null user
_updateUserData
returns Promise null
Testing these methods individually work fine, both tests below pass
test('can i register a user', function() {
return userManager._handleRegister().then(function(user) {
expect(user.uid).to.be.a('string');
console.log(userManager._user.uid);
expect(userManager._user.uid).to.be.a('string');
return userManager.signOut();
});
});
test('can i update the user with user data', function() {
return userManager._handleRegister().then(function(user) {
return userManager._updateUserData(user);
});
});
Its when i combine them into one method register()
and use it in the tests setup the error happens.
Whats the difference?
Aucun commentaire:
Enregistrer un commentaire