mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 03:17:34 +00:00
LibJS: Implement Temporal.PlainYearMonth.prototype.toPlainDate()
This commit is contained in:
parent
99adb54391
commit
2c222ba40b
5 changed files with 115 additions and 0 deletions
|
@ -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");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue