From 204ec287331f4ac03c80f57f655c02bde2db18e4 Mon Sep 17 00:00:00 2001 From: Alex Varju Date: Tue, 17 Sep 2013 17:47:19 -0700 Subject: [PATCH 1/3] rename sinon definitions now that newer versions are supported --- i18next/i18next-tests.ts | 2 +- sinon/sinon-tests.ts | 4 ++-- sinon/{sinon-1.5.d.ts => sinon.d.ts} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename sinon/{sinon-1.5.d.ts => sinon.d.ts} (100%) diff --git a/i18next/i18next-tests.ts b/i18next/i18next-tests.ts index a0fbd4332..7a07ed829 100644 --- a/i18next/i18next-tests.ts +++ b/i18next/i18next-tests.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// diff --git a/sinon/sinon-tests.ts b/sinon/sinon-tests.ts index 4c508b196..78ee261ab 100644 --- a/sinon/sinon-tests.ts +++ b/sinon/sinon-tests.ts @@ -1,4 +1,4 @@ -/// +/// function once(fn) { var returnValue, called = false; @@ -87,4 +87,4 @@ testFour(); testFive(); testSix(); testSeven(); -testEight(); \ No newline at end of file +testEight(); diff --git a/sinon/sinon-1.5.d.ts b/sinon/sinon.d.ts similarity index 100% rename from sinon/sinon-1.5.d.ts rename to sinon/sinon.d.ts From 2b69839469329de1e1f23eb1a20b3e8bf1c96017 Mon Sep 17 00:00:00 2001 From: Alex Varju Date: Tue, 17 Sep 2013 18:11:50 -0700 Subject: [PATCH 2/3] improve signatures for sinon sandbox methods --- sinon/sinon-tests.ts | 16 ++++++++++++++-- sinon/sinon.d.ts | 11 ++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) 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; } From 3369d546a148494b9c9e7fa4304c1ab56bfc7dd5 Mon Sep 17 00:00:00 2001 From: Alex Varju Date: Tue, 17 Sep 2013 18:25:00 -0700 Subject: [PATCH 3/3] sinon expectations extend the stub class --- sinon/sinon.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sinon/sinon.d.ts b/sinon/sinon.d.ts index 161ea8e60..61dfafa10 100644 --- a/sinon/sinon.d.ts +++ b/sinon/sinon.d.ts @@ -123,7 +123,7 @@ interface SinonStatic { stub: SinonStubStatic; } -interface SinonExpectation { +interface SinonExpectation extends SinonStub { atLeast(n: number): SinonExpectation; atMost(n: number): SinonExpectation; never(): SinonExpectation;