From 0f5d541ed332eb6165e1d6488a900c1bac0c3da8 Mon Sep 17 00:00:00 2001 From: igrayson Date: Sat, 18 Jun 2016 10:21:17 -0700 Subject: [PATCH] Create sinon-as-promised.d.ts (#9638) * Create sinon-as-promised.d.ts * Rename sinon-as-promised reject parameter --- sinon-as-promised/sinon-as-promised-tests.ts | 11 ++++++++++ sinon-as-promised/sinon-as-promised.d.ts | 23 ++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 sinon-as-promised/sinon-as-promised-tests.ts create mode 100644 sinon-as-promised/sinon-as-promised.d.ts 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; + } + +}