Merge pull request #4381 from Agamnentzar/Sinon

sinon: fixed *withMatch methods
This commit is contained in:
Masahiro Wakame
2015-05-25 00:05:09 +09:00
2 changed files with 20 additions and 7 deletions
+13
View File
@@ -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();
+7 -7
View File
@@ -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;