diff --git a/types/sinon/ts3.1/index.d.ts b/types/sinon/ts3.1/index.d.ts index a27355e835..2157678aaa 100644 --- a/types/sinon/ts3.1/index.d.ts +++ b/types/sinon/ts3.1/index.d.ts @@ -399,7 +399,7 @@ declare namespace Sinon { * The Promise library can be overwritten using the usingPromise method. * Since sinon@2.0.0 */ - resolves(value?: TReturnValue extends Promise ? TResolveValue : never): SinonStub; + resolves(value?: TReturnValue extends PromiseLike ? TResolveValue : never): SinonStub; /** * Causes the stub to return a Promise which resolves to the argument at the provided index. * stub.resolvesArg(0); causes the stub to return a Promise which resolves to the first argument. diff --git a/types/sinon/ts3.1/sinon-tests.ts b/types/sinon/ts3.1/sinon-tests.ts index a123f560fb..0f07193704 100644 --- a/types/sinon/ts3.1/sinon-tests.ts +++ b/types/sinon/ts3.1/sinon-tests.ts @@ -1,4 +1,5 @@ import sinon = require("sinon"); +import Bluebird = require("bluebird"); function testSandbox() { const obj = {}; @@ -426,6 +427,7 @@ function testStub() { const obj = class { foo() { } promiseFunc() { return Promise.resolve('foo'); } + promiseLikeFunc() { return {} as any as Bluebird; } }; const instance = new obj(); @@ -434,10 +436,12 @@ function testStub() { const spy: sinon.SinonSpy = stub; - function promiseFunc(n: number) { return Promise.resolve('foo'); } const promiseStub = sinon.stub(instance, 'promiseFunc'); promiseStub.resolves('test'); + const promiseLikeStub = sinon.stub(instance, 'promiseLikeFunc'); + promiseLikeStub.resolves('test'); + sinon.stub(instance); stub.reset();