Skip to content

Commit

Permalink
feat: add test for issue #450
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeduboc authored and fatso83 committed Nov 21, 2022
1 parent c6ddc8b commit bf302bd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/fake-timers-test.js
Expand Up @@ -53,6 +53,25 @@ const utilPromisifyAvailable = promisePresent && utilPromisify;
const timeoutResult = global.setTimeout(NOOP, 0);
const addTimerReturnsObject = typeof timeoutResult === "object";

describe("issue #450: `runToLastAsync` should not cause infinite loop", function () {
it("when now is set with createClock", function () {
this.clock = FakeTimers.createClock(GlobalDate.now());
const test = this;
const spy = sinon.spy();
const recursiveCallback = function () {
global.Promise.resolve().then(function () {
test.clock.setTimeout(recursiveCallback, 0);
});
};

this.clock.setTimeout(recursiveCallback, 0);
this.clock.setTimeout(spy, 100);

return this.clock.runToLastAsync().then(function () {
assert.isTrue(spy.called);
});
});
});
describe("issue #2449: permanent loss of native functions", function () {
it("should not fake faked timers", function () {
const currentTime = new Date().getTime();
Expand Down

0 comments on commit bf302bd

Please sign in to comment.