我应该如何测试拒绝:
return new Promise(function(resolve, reject){
models.users.find({
where: {
email: email
}
}).then(function(result){
if(!result)
throw 'Invalid password'
}).catch(function(err){
reject(err);
});
});
在我的测试中:
it('should be rejected', function(){
let data= { req: {
email: 'alvin@.oc',
}};
return User.authUser(data).should.be.rejected;
});
它应该被拒绝错误“无效密码”,但我得到错误:
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure
it resolves.