mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 02:08:12 +03:00
LibJS/Tests: Add tests for Temporal.TimeZone() constructor
This commit is contained in:
parent
51c581f604
commit
439b35dc7d
Notes:
sideshowbarker
2024-07-18 10:02:51 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/439b35dc7dc Pull-request: https://github.com/SerenityOS/serenity/pull/8568 Reviewed-by: https://github.com/IdanHo Reviewed-by: https://github.com/bgianfo ✅
@ -0,0 +1,35 @@
|
||||
describe("errors", () => {
|
||||
test("called without new", () => {
|
||||
expect(() => {
|
||||
Temporal.TimeZone();
|
||||
}).toThrowWithMessage(TypeError, "Temporal.TimeZone constructor must be called with 'new'");
|
||||
});
|
||||
|
||||
test("Invalid time zone name", () => {
|
||||
expect(() => {
|
||||
new Temporal.TimeZone("foo");
|
||||
}).toThrowWithMessage(RangeError, "Invalid time zone name");
|
||||
});
|
||||
});
|
||||
|
||||
describe("normal behavior", () => {
|
||||
test("length is 1", () => {
|
||||
expect(Temporal.TimeZone).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
expect(timeZone.id).toBe("UTC");
|
||||
expect(typeof timeZone).toBe("object");
|
||||
expect(timeZone).toBeInstanceOf(Temporal.TimeZone);
|
||||
expect(Object.getPrototypeOf(timeZone)).toBe(Temporal.TimeZone.prototype);
|
||||
});
|
||||
|
||||
test("canonicalizes time zone name", () => {
|
||||
expect(new Temporal.TimeZone("Utc").id).toBe("UTC");
|
||||
expect(new Temporal.TimeZone("utc").id).toBe("UTC");
|
||||
expect(new Temporal.TimeZone("uTC").id).toBe("UTC");
|
||||
});
|
||||
|
||||
// TODO: Add tests for time numeric zone offset once that's implemented
|
||||
});
|
Loading…
Reference in New Issue
Block a user