mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-04 16:04:45 +08:00
Merge pull request #1061 from varju/sinon-sandbox
Improve definitions to better match Sinon 1.7
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../sinon/sinon-1.5.d.ts" />
|
||||
/// <reference path="../sinon/sinon.d.ts" />
|
||||
/// <reference path="../mocha/mocha.d.ts" />
|
||||
/// <reference path="../expect.js/expect.js.d.ts" />
|
||||
/// <reference path="../js-fixtures/fixtures.d.ts" />
|
||||
|
||||
+16
-4
@@ -1,4 +1,4 @@
|
||||
/// <reference path="sinon-1.5.d.ts" />
|
||||
/// <reference path="sinon.d.ts" />
|
||||
|
||||
function once(fn) {
|
||||
var returnValue, called = false;
|
||||
@@ -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();
|
||||
@@ -87,4 +99,4 @@ testFour();
|
||||
testFive();
|
||||
testSix();
|
||||
testSeven();
|
||||
testEight();
|
||||
testEight();
|
||||
|
||||
+7
-6
@@ -123,7 +123,7 @@ interface SinonStatic {
|
||||
stub: SinonStubStatic;
|
||||
}
|
||||
|
||||
interface SinonExpectation {
|
||||
interface SinonExpectation extends SinonStub {
|
||||
atLeast(n: number): SinonExpectation;
|
||||
atMost(n: number): SinonExpectation;
|
||||
never(): SinonExpectation;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user