Add spy.named() and stub.named() (#29469)

This commit is contained in:
Florian
2018-10-05 20:08:56 +02:00
committed by Wesley Wigham
parent 9aa321f04b
commit ed22ab9858
2 changed files with 12 additions and 2 deletions

View File

@@ -295,6 +295,11 @@ declare namespace Sinon {
* Returns an Array with all callbacks return values in the order they were called, if no error is thrown.
*/
invokeCallback(...args: any[]): void;
/**
* Set the displayName of the spy or stub.
* @param name
*/
named(name: string): SinonSpy;
/**
* Returns the nth call.
* Accessing individual calls helps with more detailed behavior verification when the spy is called more than once.
@@ -530,6 +535,11 @@ declare namespace Sinon {
* @param val
*/
value(val: any): SinonStub;
/**
* Set the displayName of the spy or stub.
* @param name
*/
named(name: string): SinonStub;
/**
* Similar to callsArg.
* Causes the stub to call the first callback it receives with the provided arguments (if any).

View File

@@ -296,7 +296,7 @@ function testSpy() {
const instance = new obj();
let spy = sinon.spy();
const spyTwo = sinon.spy();
const spyTwo = sinon.spy().named('spyTwo');
spy = sinon.spy(fn);
spy = sinon.spy(instance, 'foo');
@@ -386,7 +386,7 @@ function testStub() {
const instance = new obj();
let stub = sinon.stub();
stub = sinon.stub(instance, 'foo');
stub = sinon.stub(instance, 'foo').named('namedStub');
const spy: sinon.SinonSpy = stub;