1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:47:46 +00:00

LibJS: Implement Temporal.ZonedDateTime.prototype.toPlainDate()

This commit is contained in:
Linus Groh 2021-08-05 21:54:54 +01:00
parent 96a0c201d5
commit b4ea4e86a7
3 changed files with 53 additions and 0 deletions

View file

@ -0,0 +1,23 @@
describe("correct behavior", () => {
test("length is 0", () => {
expect(Temporal.ZonedDateTime.prototype.toPlainDate).toHaveLength(0);
});
test("basic functionality", () => {
const timeZone = new Temporal.TimeZone("UTC");
const zonedDateTime = new Temporal.ZonedDateTime(1625614921000000000n, timeZone);
const plainDate = zonedDateTime.toPlainDate();
expect(plainDate).toBeInstanceOf(Temporal.PlainDate);
expect(plainDate.year).toBe(2021);
expect(plainDate.month).toBe(7);
expect(plainDate.day).toBe(6);
});
});
test("errors", () => {
test("this value must be a Temporal.ZonedDateTime object", () => {
expect(() => {
Temporal.ZonedDateTime.prototype.toPlainDate.call("foo");
}).toThrowWithMessage(TypeError, "Not a Temporal.ZonedDateTime");
});
});