mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:07:36 +00:00
LibJS: Implement Temporal.TimeZone.prototype.getOffsetNanosecondsFor()
This commit is contained in:
parent
d428787e18
commit
96e63415b6
6 changed files with 61 additions and 0 deletions
|
@ -0,0 +1,25 @@
|
|||
describe("correct behavior", () => {
|
||||
test("length is 1", () => {
|
||||
expect(Temporal.TimeZone.prototype.getOffsetNanosecondsFor).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instant = new Temporal.Instant(0n);
|
||||
expect(timeZone.getOffsetNanosecondsFor(instant)).toBe(0);
|
||||
});
|
||||
|
||||
test("custom offset", () => {
|
||||
const timeZone = new Temporal.TimeZone("+01:30");
|
||||
const instant = new Temporal.Instant(0n);
|
||||
expect(timeZone.getOffsetNanosecondsFor(instant)).toBe(5400000000000);
|
||||
});
|
||||
});
|
||||
|
||||
test("errors", () => {
|
||||
test("this value must be a Temporal.TimeZone object", () => {
|
||||
expect(() => {
|
||||
Temporal.TimeZone.prototype.getOffsetNanosecondsFor.call("foo");
|
||||
}).toThrowWithMessage(TypeError, "Not a Temporal.TimeZone");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue