Skip to content

Commit

Permalink
Add a missing test on using timers not present on a custom global
Browse files Browse the repository at this point in the history
This was present in Sinon and should be here as well
  • Loading branch information
fatso83 committed Aug 26, 2024
1 parent f1f6ab5 commit 13024b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/fake-timers-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,9 @@ function withGlobal(_global) {

if (isPresent.setImmediate) {
timers.setImmediate = _global.setImmediate;
}

if (isPresent.clearImmediate) {
timers.clearImmediate = _global.clearImmediate;
}

Expand All @@ -1077,7 +1080,7 @@ function withGlobal(_global) {
}

if (isPresent.queueMicrotask) {
timers.queueMicrotask = true;
timers.queueMicrotask = _global.queueMicrotask;
}

if (isPresent.cancelAnimationFrame) {
Expand Down
10 changes: 8 additions & 2 deletions test/fake-timers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6069,12 +6069,18 @@ describe("missing timers", function () {
});

it(`should ignore timers in toFake that are not present in "global" when passed the ignore flag: [${timer}]`, function () {
//refute.exception(function () {
FakeTimers.withGlobal({ Date }).install({
ignoreMissingTimers: true,
toFake: [timer],
});
//});
});
});

it("should throw on trying to use standard timers that are not present on the custom global", function () {
assert.exception(function () {
FakeTimers.withGlobal({ setTimeout, Date }).install({
toFake: ["setInterval"],
});
}, /cannot be faked: 'setInterval'/);
});
});

0 comments on commit 13024b8

Please sign in to comment.