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

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

This commit is contained in:
Linus Groh 2021-10-10 21:30:15 +01:00
parent 99adb54391
commit 2c222ba40b
5 changed files with 115 additions and 0 deletions

View file

@ -0,0 +1,27 @@
describe("normal behavior", () => {
test("length is 1", () => {
expect(Temporal.PlainYearMonth.prototype.toPlainDate).toHaveLength(1);
});
test("basic functionality", () => {
const plainYearMonth = new Temporal.PlainYearMonth(2021, 7);
const plainDate = plainYearMonth.toPlainDate({ day: 6 });
expect(plainDate.equals(new Temporal.PlainDate(2021, 7, 6))).toBeTrue();
});
});
describe("errors", () => {
test("argument must be an object", () => {
const plainYearMonth = new Temporal.PlainYearMonth(2021, 7);
expect(() => {
plainYearMonth.toPlainDate(42);
}).toThrowWithMessage(TypeError, "42 is not an object");
});
test("day field is required", () => {
const plainYearMonth = new Temporal.PlainYearMonth(2021, 7);
expect(() => {
plainYearMonth.toPlainDate({});
}).toThrowWithMessage(TypeError, "Required property day is missing or undefined");
});
});