mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:07:44 +00:00
LibJS: Start implementing Temporal.Calendar
Just like the previous Temporal.{Instant,TimeZone} commits, this patch adds the Calendar object itself, its constructor and prototype (currently empty), and two required abstract operations.
This commit is contained in:
parent
48b66c7a68
commit
a2f1d79765
12 changed files with 250 additions and 3 deletions
|
@ -0,0 +1,38 @@
|
|||
describe("errors", () => {
|
||||
test("called without new", () => {
|
||||
expect(() => {
|
||||
Temporal.Calendar();
|
||||
}).toThrowWithMessage(TypeError, "Temporal.Calendar constructor must be called with 'new'");
|
||||
});
|
||||
|
||||
test("argument must be coercible to string", () => {
|
||||
expect(() => {
|
||||
new Temporal.Calendar({
|
||||
toString() {
|
||||
throw new Error();
|
||||
},
|
||||
});
|
||||
}).toThrow(Error);
|
||||
});
|
||||
|
||||
test("invalid calendar identifier", () => {
|
||||
expect(() => {
|
||||
new Temporal.Calendar("foo");
|
||||
}).toThrowWithMessage(RangeError, "Invalid calendar identifier 'foo'");
|
||||
});
|
||||
});
|
||||
|
||||
describe("normal behavior", () => {
|
||||
test("length is 1", () => {
|
||||
expect(Temporal.Calendar).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
const calendar = new Temporal.Calendar("iso8601");
|
||||
// FIXME: Enable this once Temporal.Calendar.prototype.id is implemented
|
||||
// expect(calendar.id).toBe("iso8601");
|
||||
expect(typeof calendar).toBe("object");
|
||||
expect(calendar).toBeInstanceOf(Temporal.Calendar);
|
||||
expect(Object.getPrototypeOf(calendar)).toBe(Temporal.Calendar.prototype);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue