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

LibJS: Implement Temporal.ZonedDateTime.prototype.eraYear

This commit is contained in:
Linus Groh 2021-08-27 20:33:25 +01:00
parent b59e9260db
commit a8329272cc
3 changed files with 55 additions and 0 deletions

View file

@ -0,0 +1,26 @@
describe("correct behavior", () => {
test("basic functionality", () => {
const timeZone = new Temporal.TimeZone("UTC");
const zonedDateTime = new Temporal.ZonedDateTime(1625614921000000000n, timeZone);
expect(zonedDateTime.eraYear).toBeUndefined();
});
test("calendar with custom eraYear function", () => {
const timeZone = new Temporal.TimeZone("UTC");
const calendar = {
eraYear() {
return 123;
},
};
const zonedDateTime = new Temporal.ZonedDateTime(1625614921000000000n, timeZone, calendar);
expect(zonedDateTime.eraYear).toBe(123);
});
});
describe("errors", () => {
test("this value must be a Temporal.ZonedDateTime object", () => {
expect(() => {
Reflect.get(Temporal.ZonedDateTime.prototype, "eraYear", "foo");
}).toThrowWithMessage(TypeError, "Not a Temporal.ZonedDateTime");
});
});