1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:37:35 +00:00

LibJS: Implement Temporal.Instant.prototype.until

This commit is contained in:
Idan Horowitz 2021-09-06 21:28:06 +03:00 committed by Linus Groh
parent 24b78fff7d
commit 470499b2a8
4 changed files with 83 additions and 0 deletions

View file

@ -0,0 +1,20 @@
describe("correct behavior", () => {
test("length is 1", () => {
expect(Temporal.Instant.prototype.until).toHaveLength(1);
});
test("basic functionality", () => {
const instant1 = new Temporal.Instant(0n);
const instant2 = new Temporal.Instant(1625614920000000000n);
expect(instant1.until(instant2).seconds).toBe(1625614920);
expect(instant1.until(instant2, { largestUnit: "hour" }).hours).toBe(27093582);
});
});
describe("errors", () => {
test("this value must be a Temporal.Instant object", () => {
expect(() => {
Temporal.Instant.prototype.until.call("foo");
}).toThrowWithMessage(TypeError, "Not a Temporal.Instant");
});
});