0
then
チェーンにコンテキストをバインドするためにbind
を使用する次の関数があります。私は試してみて、それをテストするとき、それはユニットテストbluebird promiseバインド関数
TypeError: redisClient.hgetallAsync(...).bind is not a function
myFunc() {
let self = this;
return redisClient.hgetallAsync('abcde')
.bind({ api: self })
.then(doStuff)
.catch(err => {
// error
});
}
テスト
let redisClient = { hgetallAsync: sinon.stub() };
describe('myFunc',() => {
beforeEach(() => {
redisCLient.hgetallAsync.resolves('content!');
});
it('should do stuff',() => {
return myFunc()
.should.eventually.be.rejectedWith('Internal Server Error')
.and.be.an.instanceOf(Error)
.and.have.property('statusCode', 500);
});
});