mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:17:35 +00:00
LibJS: Implement Temporal.Now.plainDateISO()
This commit is contained in:
parent
c303bbde54
commit
f2a2e8e13c
4 changed files with 47 additions and 0 deletions
|
@ -0,0 +1,25 @@
|
|||
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.calendar.id).toBe("iso8601");
|
||||
});
|
||||
|
||||
test("custom time zone", () => {
|
||||
const timeZone = {
|
||||
getOffsetNanosecondsFor() {
|
||||
return 86400000000000;
|
||||
},
|
||||
};
|
||||
const plainDate = Temporal.Now.plainDateISO();
|
||||
const plainDateWithOffset = Temporal.Now.plainDateISO(timeZone);
|
||||
// Yes, this will fail if a day, month, or year change happens between the above two lines :^)
|
||||
expect(plainDateWithOffset.year).toBe(plainDate.year);
|
||||
expect(plainDateWithOffset.month).toBe(plainDate.month);
|
||||
expect(plainDateWithOffset.day).toBe(plainDate.day + 1);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue