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

LibJS: Implement Temporal.PlainDate.prototype.subtract()

This commit is contained in:
Linus Groh 2021-11-02 12:57:44 +01:00
parent bcd96c80f3
commit 654380c2c2
3 changed files with 41 additions and 0 deletions

View file

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