mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:47:35 +00:00
LibJS: Implement Temporal.Calendar.prototype.era()
This commit is contained in:
parent
525a7e487b
commit
f746850d1c
4 changed files with 61 additions and 0 deletions
|
@ -0,0 +1,26 @@
|
|||
describe("correct behavior", () => {
|
||||
test("length is 1", () => {
|
||||
expect(Temporal.Calendar.prototype.era).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
const plainDate = new Temporal.PlainDate(2021, 7, 6);
|
||||
const calendar = new Temporal.Calendar("iso8601");
|
||||
expect(calendar.era(plainDate)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
test("this value must be a Temporal.Calendar object", () => {
|
||||
expect(() => {
|
||||
Temporal.Calendar.prototype.era.call("foo");
|
||||
}).toThrowWithMessage(TypeError, "Not a Temporal.Calendar");
|
||||
});
|
||||
|
||||
test("argument must be date-like", () => {
|
||||
const calendar = new Temporal.Calendar("iso8601");
|
||||
expect(() => {
|
||||
calendar.era({});
|
||||
}).toThrowWithMessage(TypeError, "Required property year is missing or undefined");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue