Merge pull request #18159 from deadalusai/sinon-typed-stub-spy

[sinon] Add "keyof" type checking to sinon.spy and sinon.stub
This commit is contained in:
Wesley Wigham
2017-07-18 09:48:15 -07:00
committed by GitHub
2 changed files with 8 additions and 8 deletions
+4 -4
View File
@@ -96,8 +96,8 @@ declare namespace Sinon {
interface SinonSpyStatic {
(): SinonSpy;
(func: any): SinonSpy;
(obj: any, method: string): SinonSpy;
(func: Function): SinonSpy;
<T>(obj: T, method: keyof T): SinonSpy;
}
interface SinonStatic {
@@ -153,8 +153,8 @@ declare namespace Sinon {
interface SinonStubStatic {
(): SinonStub;
(obj: any): SinonStub;
(obj: any, method: string): SinonStub;
(obj: any, method: string, func: any): SinonStub;
<T>(obj: T, method: keyof T): SinonStub;
<T>(obj: T, method: keyof T, func: Function): SinonStub;
}
interface SinonStatic {
+4 -4
View File
@@ -30,7 +30,7 @@ function testTwo() {
function testThree() {
let obj = { thisObj: true };
let callback = sinon.spy({}, "method");
let callback = sinon.spy<any>({}, "method");
let proxy = once(callback);
proxy.call(obj, callback, 1, 2, 3);
if (callback.calledOn(obj)) { console.log("test3 calledOn success"); } else { console.log("test3 calledOn failure"); }
@@ -168,7 +168,7 @@ function testSetMatcher() {
}
function testGetterStub() {
const myObj: any = {
const myObj = {
prop: 'foo'
};
@@ -177,7 +177,7 @@ function testGetterStub() {
}
function testSetterStub() {
const myObj: any = {
const myObj = {
prop: 'foo',
prop2: 'bar'
};
@@ -187,7 +187,7 @@ function testSetterStub() {
}
function testValueStub() {
const myObj: any = {
const myObj = {
prop: 'foo'
};