mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
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:
Vendored
+4
-4
@@ -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 {
|
||||
|
||||
@@ -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'
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user