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

LibJS: Implement Temporal.PlainMonthDay.prototype.getISOFields()

This commit is contained in:
Linus Groh 2021-08-15 01:17:52 +01:00
parent 7fb05eb878
commit 1549845389
3 changed files with 57 additions and 0 deletions

View file

@ -0,0 +1,27 @@
describe("normal behavior", () => {
test("length is 0", () => {
expect(Temporal.PlainMonthDay.prototype.getISOFields).toHaveLength(0);
});
test("basic functionality", () => {
const calendar = new Temporal.Calendar("iso8601");
const plainMonthDay = new Temporal.PlainMonthDay(7, 6, calendar, 2021);
const fields = plainMonthDay.getISOFields();
expect(fields).toEqual({ calendar, isoDay: 6, isoMonth: 7, isoYear: 2021 });
// Test field order
expect(Object.getOwnPropertyNames(fields)).toEqual([
"calendar",
"isoDay",
"isoMonth",
"isoYear",
]);
});
});
describe("errors", () => {
test("this value must be a Temporal.PlainMonthDay object", () => {
expect(() => {
Temporal.PlainMonthDay.prototype.getISOFields.call("foo");
}).toThrowWithMessage(TypeError, "Not a Temporal.PlainMonthDay");
});
});