mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:57:35 +00:00
LibJS: Implement Temporal.Instant.prototype.since
This commit is contained in:
parent
470499b2a8
commit
4b5aa2102c
4 changed files with 83 additions and 0 deletions
|
@ -0,0 +1,20 @@
|
|||
describe("correct behavior", () => {
|
||||
test("length is 1", () => {
|
||||
expect(Temporal.Instant.prototype.since).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
const instant1 = new Temporal.Instant(1625614920000000000n);
|
||||
const instant2 = new Temporal.Instant(0n);
|
||||
expect(instant1.since(instant2).seconds).toBe(1625614920);
|
||||
expect(instant1.since(instant2, { largestUnit: "hour" }).hours).toBe(27093582);
|
||||
});
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
test("this value must be a Temporal.Instant object", () => {
|
||||
expect(() => {
|
||||
Temporal.Instant.prototype.since.call("foo");
|
||||
}).toThrowWithMessage(TypeError, "Not a Temporal.Instant");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue