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

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

This commit is contained in:
Linus Groh 2021-08-08 00:35:27 +01:00
parent 5a260fcad1
commit 7d8c182359
3 changed files with 57 additions and 0 deletions

View file

@ -0,0 +1,27 @@
describe("normal behavior", () => {
test("length is 0", () => {
expect(Temporal.PlainYearMonth.prototype.getISOFields).toHaveLength(0);
});
test("basic functionality", () => {
const calendar = new Temporal.Calendar("iso8601");
const plainYearMonth = new Temporal.PlainYearMonth(2021, 7, calendar, 6);
const fields = plainYearMonth.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.PlainYearMonth object", () => {
expect(() => {
Temporal.PlainYearMonth.prototype.getISOFields.call("foo");
}).toThrowWithMessage(TypeError, "Not a Temporal.PlainYearMonth");
});
});