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

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

This commit is contained in:
Linus Groh 2021-11-02 00:52:07 +01:00
parent 643a2433db
commit c4e371b3da
3 changed files with 48 additions and 0 deletions

View file

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