diff --git a/sinon-as-promised/sinon-as-promised-tests.ts b/sinon-as-promised/sinon-as-promised-tests.ts new file mode 100644 index 0000000000..97ff6aaa3c --- /dev/null +++ b/sinon-as-promised/sinon-as-promised-tests.ts @@ -0,0 +1,11 @@ +/// +function testResolve() { + sinon.stub().resolves('test val'); +} + +function testReject() { + sinon.stub().rejects('test val'); +} + +testResolve(); +testReject(); diff --git a/sinon-as-promised/sinon-as-promised.d.ts b/sinon-as-promised/sinon-as-promised.d.ts new file mode 100644 index 0000000000..3a214ea254 --- /dev/null +++ b/sinon-as-promised/sinon-as-promised.d.ts @@ -0,0 +1,23 @@ +// Type definitions for sinon-as-promised v4.0.0 +// Project: https://github.com/bendrucker/sinon-as-promised +// Definitions by: igrayson +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace Sinon { + + export interface SinonStub { + + /** + * When called, the stub will return a "thenable" object which will return a promise for the provided value. Any Promises/A+ compliant library will handle this object properly. + */ + resolves(value:any):SinonStub; + + /** + * When called, the stub will return a thenable which will return a reject promise with the provided err. If err is a string, it will be set as the message on an Error object. + */ + rejects(err:any):SinonStub; + } + +}