1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 20:28:11 +00:00

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

This commit is contained in:
Linus Groh 2021-11-27 17:02:51 +00:00
parent d748f2bea2
commit acbcd64cdc
3 changed files with 95 additions and 0 deletions

View file

@ -0,0 +1,19 @@
describe("correct behavior", () => {
test("length is 1", () => {
expect(Temporal.PlainYearMonth.prototype.add).toHaveLength(1);
});
test("basic functionality", () => {
const plainYearMonth = new Temporal.PlainYearMonth(1970, 1);
const result = plainYearMonth.add(new Temporal.Duration(51, 6));
expect(result.equals(new Temporal.PlainYearMonth(2021, 7))).toBeTrue();
});
});
describe("errors", () => {
test("this value must be a Temporal.PlainYearMonth object", () => {
expect(() => {
Temporal.PlainYearMonth.prototype.add.call("foo");
}).toThrowWithMessage(TypeError, "Not an object of type Temporal.PlainYearMonth");
});
});