LibJS/Tests: Add tests for Date.prototype.toTemporalInstant()

This commit is contained in:
Linus Groh 2021-07-09 00:41:09 +01:00
commit 9f2dd89446
Notes: sideshowbarker 2024-07-18 10:00:52 +09:00

View file

@ -0,0 +1,15 @@
describe("correct behavior", () => {
test("basic functionality", () => {
const date = new Date("2021-07-09T01:36:00Z");
const instant = date.toTemporalInstant();
expect(instant.epochSeconds).toBe(1625794560);
});
});
test("errors", () => {
test("this value must be a Date object", () => {
expect(() => {
Date.prototype.toTemporalInstant.call(123);
}).toThrowWithMessage(TypeError, "Not a Date object");
});
});