So I'm a new convert to Bluebird from angular and I'm trying to build unit tests for code that uses Bluebird promises. The code I want to test looks like this:
user {
handleAuth(token) {
console.log(token);
},
login(username, password, saveUsername) {
return lib.login(username, password).then(this.handleAuth.bind(this));
},
}
I've mocked out lib.login which returns a promise to instead return a resolved value like this
lib.login.and.returnValue(Promise.resolve(true));
But the handler is not executed in the space of the unit test. In the Angular world, I would need to tell the $timeout service to flush and all the resolved promises would execute their chained methods. What's the equivalent in Bluebird?
Aucun commentaire:
Enregistrer un commentaire