diff --git a/sinon/sinon-tests.ts b/sinon/sinon-tests.ts index 78ee261ab..60751e908 100644 --- a/sinon/sinon-tests.ts +++ b/sinon/sinon-tests.ts @@ -19,7 +19,7 @@ function testOne() { } function testTwo() { - var callback = sinon.spy(); + var callback = sinon.spy(() => {}); var proxy = once(callback); proxy(); proxy(); @@ -28,7 +28,7 @@ function testTwo() { function testThree() { var obj = { thisObj: true }; - var callback = sinon.spy(); + var callback = sinon.spy({}, "method"); var 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"); } @@ -80,6 +80,18 @@ function testEight() { var combinedMatcher = sinon.match.typeOf("object").and(sinon.match.has("pages")); } +function testSandbox() { + var sandbox = sinon.sandbox.create(); + if (sandbox.spy().called) { + sandbox.stub(objectUnderTest, "process").yieldsTo("success"); + sandbox.mock(objectUnderTest).expects("process").once(); + } + sandbox.useFakeTimers(); + sandbox.useFakeXMLHttpRequest(); + sandbox.useFakeServer(); + sandbox.restore(); +} + testOne(); testTwo(); testThree(); diff --git a/sinon/sinon.d.ts b/sinon/sinon.d.ts index 0ae83aa4d..161ea8e60 100644 --- a/sinon/sinon.d.ts +++ b/sinon/sinon.d.ts @@ -347,11 +347,12 @@ interface SinonSandbox { clock: SinonFakeTimers; requests: SinonFakeXMLHttpRequest; server: SinonFakeServer; - spy(): SinonSpy; - stub(): SinonStub; - mock(): SinonMock; - useFakeTimers: SinonFakeTimers; - useFakeXMLHttpRequest: SinonFakeXMLHttpRequest; + spy: SinonSpyStatic; + stub: SinonStubStatic; + mock: SinonMockStatic; + useFakeTimers: SinonFakeTimersStatic; + useFakeXMLHttpRequest: SinonFakeXMLHttpRequestStatic; + useFakeServer(): SinonFakeServer; restore(): void; }