Skip to content

Commit

Permalink
test: add performance object test
Browse files Browse the repository at this point in the history
  • Loading branch information
edusperoni authored and NathanWalker committed Jan 18, 2025
1 parent 8b320a4 commit b73693a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions TestRunner/app/tests/RuntimeImplementedAPIs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,31 @@ describe("Runtime exposes", function () {
expect(Math.abs(dateDelta - timeDelta)).toBeLessThan(dateDelta * 0.25);
});
});

describe("Performance object", () => {
it("should be available", () => {
expect(performance).toBeDefined();
});
it("should have a now function", () => {
expect(performance.now).toBeDefined();
});
it("should have a now function that returns a number", () => {
expect(typeof performance.now()).toBe("number");
});
it("should have timeOrigin", () => {
expect(performance.timeOrigin).toBeDefined();
});
it("should have timeOrigin that is a number", () => {
expect(typeof performance.timeOrigin).toBe("number");
});
it("should have timeOrigin that is greater than 0", () => {
expect(performance.timeOrigin).toBeGreaterThan(0);
});
it("should be close to the current time", () => {
const dateNow = Date.now();
const performanceNow = performance.now();
const timeOrigin = performance.timeOrigin;
const performanceAccurateNow = timeOrigin + performanceNow;
expect(Math.abs(dateNow - performanceAccurateNow)).toBeLessThan(10);
});
});

0 comments on commit b73693a

Please sign in to comment.