I'm trying to test a spy that would be called in the .then block of a promise, but the done in the then block doesn't seem to be executed at all.
Here's what I'm testing (async):
/**
* Passed down to the LoginForm component to
* handle form submission.
*/
_submitHandler(data) {
return function(evt) {
evt.preventDefault && evt.preventDefault();
evt.stopPropagation && evt.stopPropagation();
return request('post', 'auth', data)
.then((res) => {
AuthActions.login();
return res;
})
}
}
Here's my test:
describe('when it succeeds', () => {
it('should login', (done) => {
sinon.spy(AuthActions, 'login');
Instance._submitHandler({})({})
.then((res) => {
console.log('Called!!!');
expect(AuthActions.login.called).to.equal(true);
AuthActions.login.restore();
done();
}, done);
});
});
I'm using Karma to run my tests; Chai and Sinon.
Aucun commentaire:
Enregistrer un commentaire