mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:57:45 +00:00
LibJS: Implement Temporal.ZonedDateTime.prototype.era
This commit is contained in:
parent
f59e4d6738
commit
b59e9260db
3 changed files with 55 additions and 0 deletions
|
@ -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.era).toBeUndefined();
|
||||
});
|
||||
|
||||
test("calendar with custom era function", () => {
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const calendar = {
|
||||
era() {
|
||||
return "foo";
|
||||
},
|
||||
};
|
||||
const zonedDateTime = new Temporal.ZonedDateTime(1625614921000000000n, timeZone, calendar);
|
||||
expect(zonedDateTime.era).toBe("foo");
|
||||
});
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
test("this value must be a Temporal.ZonedDateTime object", () => {
|
||||
expect(() => {
|
||||
Reflect.get(Temporal.ZonedDateTime.prototype, "era", "foo");
|
||||
}).toThrowWithMessage(TypeError, "Not a Temporal.ZonedDateTime");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue