mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
sinon: resolve any in worst case (#36119)
* sinon: resolve any in worst case * add sinon test
This commit is contained in:
parent
6e43367819
commit
9d26e2f044
2
types/sinon/ts3.1/index.d.ts
vendored
2
types/sinon/ts3.1/index.d.ts
vendored
@ -404,7 +404,7 @@ declare namespace Sinon {
|
||||
* The Promise library can be overwritten using the usingPromise method.
|
||||
* Since sinon@2.0.0
|
||||
*/
|
||||
resolves(value?: TReturnValue extends PromiseLike<infer TResolveValue> ? TResolveValue : never): SinonStub<TArgs, TReturnValue>;
|
||||
resolves(value?: TReturnValue extends PromiseLike<infer TResolveValue> ? TResolveValue : any): SinonStub<TArgs, TReturnValue>;
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@ -491,6 +491,7 @@ function testStub() {
|
||||
foo(arg: string): number { return 1; }
|
||||
promiseFunc() { return Promise.resolve('foo'); }
|
||||
promiseLikeFunc() { return Promise.resolve('foo') as PromiseLike<string>; }
|
||||
unresolvableReturnFunc(): any { return Promise.resolve(); }
|
||||
fooDeep(arg: { s: string }): void { return undefined; }
|
||||
};
|
||||
const instance = new obj();
|
||||
@ -501,6 +502,11 @@ function testStub() {
|
||||
|
||||
const promiseStub = sinon.stub(instance, 'promiseFunc');
|
||||
promiseStub.resolves('test');
|
||||
promiseStub.resolves(123); // $ExpectError
|
||||
|
||||
const promiseUnresolvableReturn =
|
||||
sinon.stub(instance, 'unresolvableReturnFunc');
|
||||
promiseUnresolvableReturn.resolves(['anything', 123, true]);
|
||||
|
||||
const promiseLikeStub = sinon.stub(instance, 'promiseLikeFunc');
|
||||
promiseLikeStub.resolves('test');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user