mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 21:29:06 +00:00
LibJS: Implement Temporal.Now
This commit is contained in:
parent
f1c3e3d71a
commit
f2c19f96f8
Notes:
github-actions[bot]
2024-11-25 12:33:55 +00:00
Author: https://github.com/trflynn89
Commit: f2c19f96f8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2557
Reviewed-by: https://github.com/shannonbooth ✅
12 changed files with 252 additions and 0 deletions
|
@ -0,0 +1,3 @@
|
|||
test("basic functionality", () => {
|
||||
expect(Temporal.Now[Symbol.toStringTag]).toBe("Temporal.Now");
|
||||
});
|
|
@ -0,0 +1,19 @@
|
|||
describe("correct behavior", () => {
|
||||
test("length is 0", () => {
|
||||
expect(Temporal.Now.plainDateISO).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
const plainDate = Temporal.Now.plainDateISO();
|
||||
expect(plainDate).toBeInstanceOf(Temporal.PlainDate);
|
||||
expect(plainDate.calendarId).toBe("iso8601");
|
||||
});
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
test("invalid time zone name", () => {
|
||||
expect(() => {
|
||||
Temporal.Now.plainDateISO("foo");
|
||||
}).toThrowWithMessage(RangeError, "Invalid time zone name 'foo");
|
||||
});
|
||||
});
|
|
@ -0,0 +1,19 @@
|
|||
describe("correct behavior", () => {
|
||||
test("length is 0", () => {
|
||||
expect(Temporal.Now.plainDateTimeISO).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
const plainDateTime = Temporal.Now.plainDateTimeISO();
|
||||
expect(plainDateTime).toBeInstanceOf(Temporal.PlainDateTime);
|
||||
expect(plainDateTime.calendarId).toBe("iso8601");
|
||||
});
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
test("invalid time zone name", () => {
|
||||
expect(() => {
|
||||
Temporal.Now.plainDateTimeISO("foo");
|
||||
}).toThrowWithMessage(RangeError, "Invalid time zone name 'foo");
|
||||
});
|
||||
});
|
|
@ -0,0 +1,19 @@
|
|||
describe("correct behavior", () => {
|
||||
test("length is 0", () => {
|
||||
expect(Temporal.Now.plainTimeISO).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
const plainTime = Temporal.Now.plainTimeISO();
|
||||
expect(plainTime).toBeInstanceOf(Temporal.PlainTime);
|
||||
expect(plainTime.calendarId).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
test("invalid time zone name", () => {
|
||||
expect(() => {
|
||||
Temporal.Now.plainTimeISO("foo");
|
||||
}).toThrowWithMessage(RangeError, "Invalid time zone name 'foo");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue