我试图测试一个间谍将被称为承诺的.then
块,但块done
似乎并未执行在所有。摩卡 - 测试承诺,`完成`永远不会被调用在承诺
我越来越timeout of 2000ms exceeded.
这里是我测试(异步):
/**
* 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;
})
}
}
这里是我的测试:
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);
});
});
我使用噶运行我的测试;柴和诗乃。
你会得到什么失败的消息? – Bergi