From 639337b32bed76f70e1e7918c4ad076c4492e1ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Eichler?= Date: Mon, 18 May 2015 14:57:14 +0200 Subject: [PATCH] fixed *withMatch methods incorrectly requiring SinonMatcher type arguments --- sinon/sinon-tests.ts | 13 +++++++++++++ sinon/sinon.d.ts | 14 +++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/sinon/sinon-tests.ts b/sinon/sinon-tests.ts index ccc9819e5..ca916788d 100644 --- a/sinon/sinon-tests.ts +++ b/sinon/sinon-tests.ts @@ -76,6 +76,18 @@ function testEight() { sinon.match.typeOf("object").and(sinon.match.has("pages")); } +function testNine() { + var callback = sinon.stub().returns(42); + callback({ x: 5, y: 5 }); + callback.calledWithMatch({ x: 5 }); + callback.alwaysCalledWithMatch({ y: 5 }); + callback.neverCalledWithMatch({ x: 6 }); + callback.notCalledWithMatch({ x: 6 }); + sinon.assert.calledWithMatch(callback, { x: 5 }); + sinon.assert.alwaysCalledWithMatch(callback, { y: 5 }); + sinon.assert.neverCalledWithMatch(callback, { x: 6 }); +} + function testSandbox() { var sandbox = sinon.sandbox.create(); if (sandbox.spy().called) { @@ -96,3 +108,4 @@ testFive(); testSix(); testSeven(); testEight(); +testNine(); diff --git a/sinon/sinon.d.ts b/sinon/sinon.d.ts index 7dc5bc1d6..6440dda90 100644 --- a/sinon/sinon.d.ts +++ b/sinon/sinon.d.ts @@ -15,9 +15,9 @@ declare module Sinon { calledOn(obj: any): boolean; calledWith(...args: any[]): boolean; calledWithExactly(...args: any[]): boolean; - calledWithMatch(...args: SinonMatcher[]): boolean; + calledWithMatch(...args: any[]): boolean; notCalledWith(...args: any[]): boolean; - notCalledWithMatch(...args: SinonMatcher[]): boolean; + notCalledWithMatch(...args: any[]): boolean; returned(value: any): boolean; threw(): boolean; threw(type: string): boolean; @@ -64,9 +64,9 @@ declare module Sinon { alwaysCalledOn(obj: any): boolean; alwaysCalledWith(...args: any[]): boolean; alwaysCalledWithExactly(...args: any[]): boolean; - alwaysCalledWithMatch(...args: SinonMatcher[]): boolean; + alwaysCalledWithMatch(...args: any[]): boolean; neverCalledWith(...args: any[]): boolean; - neverCalledWithMatch(...args: SinonMatcher[]): boolean; + neverCalledWithMatch(...args: any[]): boolean; alwaysThrew(): boolean; alwaysThrew(type: string): boolean; alwaysThrew(obj: any): boolean; @@ -307,9 +307,9 @@ declare module Sinon { neverCalledWith(spy: SinonSpy, ...args: any[]): void; calledWithExactly(spy: SinonSpy, ...args: any[]): void; alwaysCalledWithExactly(spy: SinonSpy, ...args: any[]): void; - calledWithMatch(spy: SinonSpy, ...args: SinonMatcher[]): void; - alwaysCalledWithMatch(spy: SinonSpy, ...args: SinonMatcher[]): void; - neverCalledWithMatch(spy: SinonSpy, ...args: SinonMatcher[]): void; + calledWithMatch(spy: SinonSpy, ...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;