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

LibJS: Implement Temporal.PlainDateTime.prototype.eraYear

This commit is contained in:
Linus Groh 2021-08-27 20:18:37 +01:00
parent 276d3f5089
commit f2f671f340
3 changed files with 42 additions and 0 deletions

View file

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