Promise bug in sample code
alecl opened this issue · comments
Alec Lazarescu commented
If I run it as written I get the following:
Error: Resolution method is overspecified. Specify a callback or return a Promise; not both.
it('should return `help message` if user types `help`', (done)=>{
var self = this;
return self.controller.usersInput([{
first:true,
user: self.slackId,
messages:[{text: 'help', isAssertion:true}]
}]).then((text)=>{
assert.equal(text, 'help message')
done()
})
});
If I remove the done and just return the promise it's fine. Also, suggest adding a catch and return rejection or you miss out on important errors
it('should return `help message` if user types `help`', ()=>{
var self = this;
return self.controller.usersInput([{
first:true,
user: self.slackId,
messages:[{text: 'help', isAssertion:true}]
}])
.catch((err) => {
return Promise.reject(err);
}).then((text) => {
assert.equal(text, 'help message')
})
});
Alec Lazarescu commented
Fixed in PR #16
Ihor Rusinko commented
yeah, make sense. ty