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

LibJS: Implement Temporal.TimeZone.prototype.getOffsetStringFor()

This commit is contained in:
Linus Groh 2021-07-31 21:54:35 +01:00
parent f987c11464
commit c4123d8aad
6 changed files with 64 additions and 0 deletions

View file

@ -0,0 +1,25 @@
describe("correct behavior", () => {
test("length is 1", () => {
expect(Temporal.TimeZone.prototype.getOffsetStringFor).toHaveLength(1);
});
test("basic functionality", () => {
const timeZone = new Temporal.TimeZone("UTC");
const instant = new Temporal.Instant(0n);
expect(timeZone.getOffsetStringFor(instant)).toBe("+00:00");
});
test("custom offset", () => {
const timeZone = new Temporal.TimeZone("+01:30");
const instant = new Temporal.Instant(0n);
expect(timeZone.getOffsetStringFor(instant)).toBe("+01:30");
});
});
test("errors", () => {
test("this value must be a Temporal.TimeZone object", () => {
expect(() => {
Temporal.TimeZone.prototype.getOffsetStringFor.call("foo");
}).toThrowWithMessage(TypeError, "Not a Temporal.TimeZone");
});
});