diff --git a/types/sinon/index.d.ts b/types/sinon/index.d.ts index f0433a694e..5d3288068d 100644 --- a/types/sinon/index.d.ts +++ b/types/sinon/index.d.ts @@ -353,19 +353,20 @@ declare namespace Sinon { calledThrice(spy: SinonSpy): void; callCount(spy: SinonSpy, count: number): void; callOrder(...spies: SinonSpy[]): void; - calledOn(spy: SinonSpy, obj: any): void; + calledOn(spyOrSpyCall: SinonSpy | SinonSpyCall, obj: any): void; alwaysCalledOn(spy: SinonSpy, obj: any): void; - calledWith(spy: SinonSpy, ...args: any[]): void; + calledWith(spyOrSpyCall: SinonSpy | SinonSpyCall, ...args: any[]): void; alwaysCalledWith(spy: SinonSpy, ...args: any[]): void; neverCalledWith(spy: SinonSpy, ...args: any[]): void; - calledWithExactly(spy: SinonSpy, ...args: any[]): void; + calledWithExactly(spyOrSpyCall: SinonSpy | SinonSpyCall, ...args: any[]): void; alwaysCalledWithExactly(spy: SinonSpy, ...args: any[]): void; - calledWithMatch(spy: SinonSpy, ...args: any[]): void; + calledWithMatch(spyOrSpyCall: SinonSpy | SinonSpyCall, ...args: any[]): void; alwaysCalledWithMatch(spy: SinonSpy, ...args: any[]): void; neverCalledWithMatch(spy: SinonSpy, ...args: any[]): void; - threw(spy: SinonSpy): void; - threw(spy: SinonSpy, exception: string): void; - threw(spy: SinonSpy, exception: any): void; + calledWithNew(spyOrSpyCall: SinonSpy | SinonSpyCall): void; + threw(spyOrSpyCall: SinonSpy | SinonSpyCall): void; + threw(spyOrSpyCall: SinonSpy | SinonSpyCall, exception: string): void; + threw(spyOrSpyCall: SinonSpy | SinonSpyCall, exception: any): void; alwaysThrew(spy: SinonSpy): void; alwaysThrew(spy: SinonSpy, exception: string): void; alwaysThrew(spy: SinonSpy, exception: any): void; diff --git a/types/sinon/sinon-tests.ts b/types/sinon/sinon-tests.ts index 2e2286e538..6ce2254596 100644 --- a/types/sinon/sinon-tests.ts +++ b/types/sinon/sinon-tests.ts @@ -88,6 +88,21 @@ function testNine() { sinon.assert.calledWithMatch(callback, { x: 5 }); sinon.assert.alwaysCalledWithMatch(callback, { y: 5 }); sinon.assert.neverCalledWithMatch(callback, { x: 6 }); + + callback.call("this", "that"); + callback.throws("Error"); + try { + callback(15); + } catch (e) { } + sinon.assert.calledWith(callback.firstCall, { x: 5, y: 5}); + sinon.assert.calledWithExactly(callback.firstCall, { x: 5, y: 5 }); + sinon.assert.calledWithMatch(callback.firstCall, { x: 5 }); + sinon.assert.calledOn(callback.secondCall, "this"); + sinon.assert.threw(callback.thirdCall); + sinon.assert.threw(callback.thirdCall, "Error"); + new (callback as any)(); + sinon.assert.calledWithNew(callback); + sinon.assert.calledWithNew(callback.getCall(4)); } function testAssert() {