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

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

This commit is contained in:
Linus Groh 2021-08-16 18:42:15 +01:00
parent 7d23d9d557
commit c1ffc17134
3 changed files with 57 additions and 0 deletions

View file

@ -0,0 +1,30 @@
describe("correct behavior", () => {
test("length is 1", () => {
expect(Temporal.Calendar.prototype.fields).toHaveLength(1);
});
test("basic functionality", () => {
const calendar = new Temporal.Calendar("iso8601");
const array = ["foo", "bar", "baz"];
const fields = calendar.fields(array);
expect(fields).toEqual(array);
expect(fields).not.toBe(array);
});
});
describe("errors", () => {
test("this value must be a Temporal.Calendar object", () => {
expect(() => {
Temporal.Calendar.prototype.fields.call("foo");
}).toThrowWithMessage(TypeError, "Not a Temporal.Calendar");
});
test("iterator values must be strings", () => {
const calendar = new Temporal.Calendar("iso8601");
for (const value of [123, null, undefined, true, {}]) {
expect(() => {
calendar.fields([value]);
}).toThrowWithMessage(TypeError, "FIXME: Add a string for this error.");
}
});
});