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

LibJS: Implement Temporal.PlainDate.prototype.era

This commit is contained in:
Linus Groh 2021-08-27 20:03:41 +01:00
parent c3e0d78ba6
commit 6f7d6d917e
5 changed files with 67 additions and 0 deletions

View file

@ -0,0 +1,24 @@
describe("correct behavior", () => {
test("basic functionality", () => {
const plainDate = new Temporal.PlainDate(2021, 7, 6);
expect(plainDate.era).toBeUndefined();
});
test("calendar with custom era function", () => {
const calendar = {
era() {
return "foo";
},
};
const plainDate = new Temporal.PlainDate(2021, 7, 6, calendar);
expect(plainDate.era).toBe("foo");
});
});
describe("errors", () => {
test("this value must be a Temporal.PlainDate object", () => {
expect(() => {
Reflect.get(Temporal.PlainDate.prototype, "era", "foo");
}).toThrowWithMessage(TypeError, "Not a Temporal.PlainDate");
});
});