|
@@ -26,35 +26,21 @@ describe("correct behavior", () => {
|
|
const plainDateTime = timeZone.getPlainDateTimeFor(instant, calendar);
|
|
const plainDateTime = timeZone.getPlainDateTimeFor(instant, calendar);
|
|
expect(plainDateTime.calendar).toBe(calendar);
|
|
expect(plainDateTime.calendar).toBe(calendar);
|
|
});
|
|
});
|
|
-
|
|
|
|
- test("non-TimeZone this value", () => {
|
|
|
|
- const timeZoneLike = {
|
|
|
|
- getOffsetNanosecondsFor() {
|
|
|
|
- return 123;
|
|
|
|
- },
|
|
|
|
- };
|
|
|
|
- const instant = new Temporal.Instant(0n);
|
|
|
|
- const plainDateTime = Temporal.TimeZone.prototype.getPlainDateTimeFor.call(
|
|
|
|
- timeZoneLike,
|
|
|
|
- instant
|
|
|
|
- );
|
|
|
|
- expect(plainDateTime.year).toBe(1970);
|
|
|
|
- expect(plainDateTime.month).toBe(1);
|
|
|
|
- expect(plainDateTime.day).toBe(1);
|
|
|
|
- expect(plainDateTime.hour).toBe(0);
|
|
|
|
- expect(plainDateTime.minute).toBe(0);
|
|
|
|
- expect(plainDateTime.second).toBe(0);
|
|
|
|
- expect(plainDateTime.millisecond).toBe(0);
|
|
|
|
- expect(plainDateTime.microsecond).toBe(0);
|
|
|
|
- expect(plainDateTime.nanosecond).toBe(123);
|
|
|
|
- });
|
|
|
|
});
|
|
});
|
|
|
|
|
|
describe("errors", () => {
|
|
describe("errors", () => {
|
|
- test("custom time zone doesn't have a getOffsetNanosecondsFor function", () => {
|
|
|
|
|
|
+ test("time zone doesn't have a getOffsetNanosecondsFor function", () => {
|
|
|
|
+ const timeZone = new Temporal.TimeZone("UTC");
|
|
|
|
+ timeZone.getOffsetNanosecondsFor = undefined;
|
|
const instant = new Temporal.Instant(1n);
|
|
const instant = new Temporal.Instant(1n);
|
|
expect(() => {
|
|
expect(() => {
|
|
- Temporal.TimeZone.prototype.getPlainDateTimeFor.call({}, instant);
|
|
|
|
|
|
+ timeZone.getPlainDateTimeFor(instant);
|
|
}).toThrowWithMessage(TypeError, "null is not a function");
|
|
}).toThrowWithMessage(TypeError, "null is not a function");
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ test("this value must be a Temporal.TimeZone object", () => {
|
|
|
|
+ expect(() => {
|
|
|
|
+ Temporal.TimeZone.prototype.getPlainDateTimeFor.call("foo");
|
|
|
|
+ }).toThrowWithMessage(TypeError, "Not an object of type Temporal.TimeZone");
|
|
|
|
+ });
|
|
});
|
|
});
|