1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:57:45 +00:00

LibJS: Only allow TimeZone this value in Temporal.TimeZone#toJSON

This is a normative change in the Temporal spec.

See: 2644fc6
This commit is contained in:
Luke Wilde 2021-12-18 23:06:32 +00:00 committed by Linus Groh
parent 6c8c34ed6c
commit 7729598b5b
2 changed files with 10 additions and 5 deletions

View file

@ -7,8 +7,12 @@ describe("correct behavior", () => {
const timeZone = new Temporal.TimeZone("UTC");
expect(timeZone.toJSON()).toBe("UTC");
});
});
test("works with any this value", () => {
expect(Temporal.TimeZone.prototype.toJSON.call("foo")).toBe("foo");
describe("errors", () => {
test("this value must be a Temporal.TimeZone object", () => {
expect(() => {
Temporal.TimeZone.prototype.toJSON.call("foo");
}).toThrowWithMessage(TypeError, "Not an object of type Temporal.TimeZone");
});
});