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

LibJS: Implement Temporal.Calendar.prototype.eraYear()

This commit is contained in:
Linus Groh 2021-08-27 19:52:41 +01:00
parent f746850d1c
commit c3e0d78ba6
4 changed files with 61 additions and 0 deletions

View file

@ -0,0 +1,26 @@
describe("correct behavior", () => {
test("length is 1", () => {
expect(Temporal.Calendar.prototype.eraYear).toHaveLength(1);
});
test("basic functionality", () => {
const plainDate = new Temporal.PlainDate(2021, 7, 6);
const calendar = new Temporal.Calendar("iso8601");
expect(calendar.eraYear(plainDate)).toBeUndefined();
});
});
describe("errors", () => {
test("this value must be a Temporal.Calendar object", () => {
expect(() => {
Temporal.Calendar.prototype.eraYear.call("foo");
}).toThrowWithMessage(TypeError, "Not a Temporal.Calendar");
});
test("argument must be date-like", () => {
const calendar = new Temporal.Calendar("iso8601");
expect(() => {
calendar.eraYear({});
}).toThrowWithMessage(TypeError, "Required property year is missing or undefined");
});
});