Skip to content

Commit

Permalink
Use fakeTimers in the default sandbox
Browse files Browse the repository at this point in the history
This is to allow restoring spied fakeTimers in default sandbox.
  • Loading branch information
ig-pj committed May 21, 2018
1 parent 8b6f8a8 commit 6799e1c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 0 additions & 3 deletions lib/sinon.js
Expand Up @@ -24,11 +24,8 @@ var apiMethods = {
setFormatter: format.setFormatter,

// fake timers
useFakeTimers: fakeTimers.useFakeTimers,
clock: fakeTimers.clock,
timers: fakeTimers.timers,


// fake XHR
xhr: nise.fakeXhr.xhr,
FakeXMLHttpRequest: nise.fakeXhr.FakeXMLHttpRequest,
Expand Down
13 changes: 13 additions & 0 deletions test/issues/issues-test.js
Expand Up @@ -466,4 +466,17 @@ describe("issues", function () {
// TypeError: Attempted to wrap someMethod which is already wrapped
});
});

describe("sinon.restore spied fakeTimers", function () {
it("should restore spied fake timers", function () {
var originalSetTimeout = setTimeout;

sinon.useFakeTimers();
sinon.spy(global, "setTimeout");

sinon.restore();

assert.same(originalSetTimeout, global.setTimeout, "fakeTimers restored");
});
});
});

0 comments on commit 6799e1c

Please sign in to comment.