Skip to content

Commit

Permalink
test no longer conditional and now uses built-in exception assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
itayperry committed Nov 13, 2021
1 parent 81c5e9b commit fa323c8
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions test/fake-timers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3706,20 +3706,26 @@ describe("FakeTimers", function () {
});
}

if (!performanceNowPresent) {
it("throws when adding performance to tofake array when performance not present", function () {
try {
this.clock = FakeTimers.install({
it("throws when adding performance to tofake array when performance not present", function () {
assert.exception(
function () {
const setTimeoutFake = sinon.fake();
const context = {
Date: Date,
setTimeout: setTimeoutFake,
clearTimeout: sinon.fake(),
performance: undefined,
};
FakeTimers.withGlobal(context).install({
toFake: ["performance"],
});
} catch (e) {
const expectedMsg =
"non-existent performance object cannot be faked";
assert(e instanceof ReferenceError);
assert.equals(e.message, expectedMsg);
},
{
name: "ReferenceError",
message: "non-existent performance object cannot be faked",
}
});
}
);
});

if (performanceNowPresent) {
it("replaces global performance.now", function () {
Expand Down

0 comments on commit fa323c8

Please sign in to comment.