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

LibJS/Tests: Add Temporal.Calendar.from() tests for more object types

This commit is contained in:
Linus Groh 2021-08-17 23:06:05 +01:00
parent 0cdad283c0
commit 90f7e01179

View file

@ -4,15 +4,21 @@ describe("normal behavior", () => {
});
test("basic functionality", () => {
const timeZone = new Temporal.TimeZone("UTC");
const plainDate = new Temporal.PlainDate(1970, 1, 1);
const plainTime = new Temporal.PlainTime();
const plainDateTime = new Temporal.PlainDateTime(1970, 1, 1);
// TODO: PlainMonthDay, PlainYearMonth, ZonedDateTime
const plainMonthDay = new Temporal.PlainMonthDay(1, 1);
const plainYearMonth = new Temporal.PlainYearMonth(1970, 1);
const zonedDateTime = new Temporal.ZonedDateTime(0n, timeZone);
const calendarLike = {};
const withCalendarLike = { calendar: {} };
expect(Temporal.Calendar.from(plainDate)).toBe(plainDate.calendar);
expect(Temporal.Calendar.from(plainTime)).toBe(plainTime.calendar);
expect(Temporal.Calendar.from(plainDateTime)).toBe(plainDateTime.calendar);
expect(Temporal.Calendar.from(plainMonthDay)).toBe(plainMonthDay.calendar);
expect(Temporal.Calendar.from(plainYearMonth)).toBe(plainYearMonth.calendar);
expect(Temporal.Calendar.from(zonedDateTime)).toBe(zonedDateTime.calendar);
expect(Temporal.Calendar.from(calendarLike)).toBe(calendarLike);
expect(Temporal.Calendar.from(withCalendarLike)).toBe(withCalendarLike.calendar);
expect(Temporal.Calendar.from("iso8601").id).toBe("iso8601");