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

LibJS: Implement Temporal.Duration.prototype.toJSON()

This commit is contained in:
Linus Groh 2021-11-07 01:46:15 +00:00
parent b2548393d2
commit 90fa356b93
3 changed files with 32 additions and 0 deletions

View file

@ -0,0 +1,19 @@
describe("correct behavior", () => {
test("length is 0", () => {
expect(Temporal.Duration.prototype.toJSON).toHaveLength(0);
});
test("basic functionality", () => {
expect(new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).toJSON()).toBe(
"P1Y2M3W4DT5H6M7.00800901S"
);
});
});
describe("errors", () => {
test("this value must be a Temporal.Duration object", () => {
expect(() => {
Temporal.Duration.prototype.toJSON.call("foo");
}).toThrowWithMessage(TypeError, "Not an object of type Temporal.Duration");
});
});