mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-23 01:12:45 +00:00
And the simple Temporal.ZonedDateTime.prototype getters, so that the constructed Temporal.ZonedDateTime may actually be validated.
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
describe("errors", () => {
|
|
test("called without new", () => {
|
|
expect(() => {
|
|
Temporal.ZonedDateTime();
|
|
}).toThrowWithMessage(
|
|
TypeError,
|
|
"Temporal.ZonedDateTime constructor must be called with 'new'"
|
|
);
|
|
});
|
|
|
|
test("out-of-range epoch nanoseconds value", () => {
|
|
expect(() => {
|
|
new Temporal.ZonedDateTime(8_640_000_000_000_000_000_001n);
|
|
}).toThrowWithMessage(
|
|
RangeError,
|
|
"Invalid epoch nanoseconds value, must be in range -86400 * 10^17 to 86400 * 10^17"
|
|
);
|
|
expect(() => {
|
|
new Temporal.ZonedDateTime(-8_640_000_000_000_000_000_001n);
|
|
}).toThrowWithMessage(
|
|
RangeError,
|
|
"Invalid epoch nanoseconds value, must be in range -86400 * 10^17 to 86400 * 10^17"
|
|
);
|
|
});
|
|
});
|
|
|
|
describe("normal behavior", () => {
|
|
test("length is 2", () => {
|
|
expect(Temporal.ZonedDateTime).toHaveLength(2);
|
|
});
|
|
|
|
test("basic functionality", () => {
|
|
const timeZone = "UTC";
|
|
const zonedDateTime = new Temporal.ZonedDateTime(0n, timeZone);
|
|
expect(typeof zonedDateTime).toBe("object");
|
|
expect(zonedDateTime).toBeInstanceOf(Temporal.ZonedDateTime);
|
|
expect(Object.getPrototypeOf(zonedDateTime)).toBe(Temporal.ZonedDateTime.prototype);
|
|
});
|
|
});
|