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

LibJS: Implement parsing of TemporalRelativeToString

This commit is contained in:
Linus Groh 2021-11-19 20:53:07 +00:00
parent 98b876ad3f
commit 1583c7257c
12 changed files with 370 additions and 61 deletions

View file

@ -96,7 +96,7 @@ describe("correct behavior", () => {
});
// FIXME: Enable when parse_iso_date_time is implemented.
test.skip("from string", () => {
test("from string", () => {
const zonedDateTime = Temporal.ZonedDateTime.from(
"2021-11-07T00:20:05.100200300+00:00[UTC][u-ca=iso8601]"
);
@ -106,17 +106,17 @@ describe("correct behavior", () => {
expect(zonedDateTime.timeZone.id).toBe("UTC");
expect(zonedDateTime.calendar).toBeInstanceOf(Temporal.Calendar);
expect(zonedDateTime.calendar.id).toBe("iso8601");
expect(createdZoneDateTime.year).toBe(2021);
expect(createdZoneDateTime.month).toBe(11);
expect(createdZoneDateTime.day).toBe(7);
expect(createdZoneDateTime.hour).toBe(0);
expect(createdZoneDateTime.minute).toBe(20);
expect(createdZoneDateTime.second).toBe(5);
expect(createdZoneDateTime.millisecond).toBe(100);
expect(createdZoneDateTime.microsecond).toBe(200);
expect(createdZoneDateTime.nanosecond).toBe(300);
expect(createdZoneDateTime.offset).toBe("+00:00");
expect(createdZoneDateTime.offsetNanoseconds).toBe(0);
expect(zonedDateTime.year).toBe(2021);
expect(zonedDateTime.month).toBe(11);
expect(zonedDateTime.day).toBe(7);
expect(zonedDateTime.hour).toBe(0);
expect(zonedDateTime.minute).toBe(20);
expect(zonedDateTime.second).toBe(5);
expect(zonedDateTime.millisecond).toBe(100);
expect(zonedDateTime.microsecond).toBe(200);
expect(zonedDateTime.nanosecond).toBe(300);
expect(zonedDateTime.offset).toBe("+00:00");
expect(zonedDateTime.offsetNanoseconds).toBe(0);
});
});

View file

@ -13,8 +13,7 @@ describe("correct behavior", () => {
expect(withTimeZoneZonedDateTime.timeZone).toBe(timeZone);
});
// FIXME: Enable this when time zone string parsing is implemented.
test.skip("from time zone string", () => {
test("from time zone string", () => {
const object = {};
const zonedDateTime = new Temporal.ZonedDateTime(1n, object);
expect(zonedDateTime.timeZone).toBe(object);
@ -32,13 +31,11 @@ describe("errors", () => {
}).toThrowWithMessage(TypeError, "Not an object of type Temporal.ZonedDateTime");
});
// FIXME: Enable this when time zone string parsing is implemented.
test.skip("from invalid time zone string", () => {
test("from invalid time zone string", () => {
const zonedDateTime = new Temporal.ZonedDateTime(1n, {});
// FIXME: Use "toThrowWithMessage" once this has an error message.
expect(() => {
zonedDateTime.withTimeZone("UTCfoobar");
}).toThrow(RangeError);
}).toThrowWithMessage(RangeError, "Invalid time zone string 'UTCfoobar'");
});
});