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

LibJS: Implement parsing of TemporalMonthDayString

This commit is contained in:
Linus Groh 2021-11-19 19:05:17 +00:00
parent 453c78215c
commit 3ddab2f4fe
5 changed files with 61 additions and 7 deletions

View file

@ -35,8 +35,14 @@ describe("correct behavior", () => {
expect(plainMonthDay.day).toBe(6);
});
test("from month day string", () => {
const plainMonthDay = Temporal.PlainMonthDay.from("--07-06");
expect(plainMonthDay.monthCode).toBe("M07");
expect(plainMonthDay.day).toBe(6);
});
// Un-skip once ParseISODateTime, ToTemporalMonthDay & ParseTemporalMonthDayString are fully implemented
test.skip("PlainMonthDay string argument", () => {
test.skip("from date time string", () => {
const plainMonthDay = Temporal.PlainMonthDay.from("2021-07-06T23:42:01Z");
expect(plainMonthDay.monthCode).toBe("M07");
expect(plainMonthDay.day).toBe(6);
@ -55,4 +61,10 @@ describe("errors", () => {
Temporal.PlainMonthDay.from({ day: 1 });
}).toThrowWithMessage(TypeError, "Required property month is missing or undefined");
});
test("invalid month day string", () => {
expect(() => {
Temporal.PlainMonthDay.from("foo");
}).toThrowWithMessage(RangeError, "Invalid month day string 'foo'");
});
});