Add optional message param to sinon.match overload that takes a callback

This commit is contained in:
Marcin Dobosz
2017-06-22 16:33:50 -07:00
parent 1c385f2276
commit 0837fea9eb
2 changed files with 9 additions and 1 deletions

View File

@@ -421,7 +421,7 @@ declare namespace Sinon {
(value: string): SinonMatcher;
(expr: RegExp): SinonMatcher;
(obj: any): SinonMatcher;
(callback: (value: any) => boolean): SinonMatcher;
(callback: (value: any) => boolean, message?: string): SinonMatcher;
any: SinonMatcher;
defined: SinonMatcher;
truthy: SinonMatcher;

View File

@@ -119,6 +119,14 @@ function testPromises() {
rejectsStub2 = sinon.stub().rejects("TypeError");
}
function testMatchInvoke() {
let stub = sinon.stub();
stub(123);
stub.calledWithMatch(sinon.match(123));
stub.calledWithMatch(sinon.match((value: any) => value === 123));
stub.calledWithMatch(sinon.match((value: any) => value === 123, "Must be 123"));
}
function testSymbolMatch() {
let stub = sinon.stub();
stub(Symbol('TestSymbol'));