Everywhere: Hoist the Libraries folder to the top-level

This commit is contained in:
Timothy Flynn 2024-11-09 12:25:08 -05:00 committed by Andreas Kling
commit 93712b24bf
Notes: github-actions[bot] 2024-11-10 11:51:52 +00:00
4547 changed files with 104 additions and 113 deletions

View file

@ -0,0 +1,66 @@
describe("errors", () => {
test("first argument must be coercible to object", () => {
expect(() => {
new AggregateError();
}).toThrowWithMessage(TypeError, "ToObject on null or undefined");
});
test("@@iterator throws", () => {
expect(() => {
new AggregateError({
[Symbol.iterator]() {
throw Error("oops!");
},
});
}).toThrowWithMessage(Error, "oops!");
});
});
describe("normal behavior", () => {
test("length is 2", () => {
expect(AggregateError).toHaveLength(2);
});
test("name is AggregateError", () => {
expect(AggregateError.name).toBe("AggregateError");
});
test("Prototype of the AggregateError constructor is the Error constructor", () => {
expect(Object.getPrototypeOf(AggregateError)).toBe(Error);
});
test("Prototype of AggregateError.prototype is Error.prototype", () => {
expect(Object.getPrototypeOf(AggregateError.prototype)).toBe(Error.prototype);
});
test("basic functionality", () => {
expect(AggregateError([])).toBeInstanceOf(AggregateError);
expect(new AggregateError([])).toBeInstanceOf(AggregateError);
expect(new AggregateError([]).toString()).toBe("AggregateError");
expect(new AggregateError([], "Foo").toString()).toBe("AggregateError: Foo");
expect(new AggregateError([]).hasOwnProperty("errors")).toBeTrue();
const errors = [1, 2, 3];
expect(new AggregateError(errors).errors).toEqual(errors);
expect(new AggregateError(errors).errors).not.toBe(errors);
expect(
new AggregateError({
[Symbol.iterator]: (i = 0) => ({
next() {
if (i < 3) {
i++;
return { value: i };
}
return { value: null, done: true };
},
}),
}).errors
).toEqual(errors);
});
test("supports options object with cause", () => {
const cause = new Error();
const error = new AggregateError([], "test", { cause });
expect(error.hasOwnProperty("cause")).toBeTrue();
expect(error.cause).toBe(cause);
});
});