2021-06-15 22:16:17 +03:00
|
|
|
test("constructor properties", () => {
|
|
|
|
|
expect(FinalizationRegistry).toHaveLength(1);
|
|
|
|
|
expect(FinalizationRegistry.name).toBe("FinalizationRegistry");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("errors", () => {
|
|
|
|
|
test("invalid callbacks", () => {
|
|
|
|
|
[-100, Infinity, NaN, 152n, undefined].forEach(value => {
|
|
|
|
|
expect(() => {
|
|
|
|
|
new FinalizationRegistry(value);
|
|
|
|
|
}).toThrowWithMessage(TypeError, "is not a function");
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
test("called without new", () => {
|
|
|
|
|
expect(() => {
|
|
|
|
|
FinalizationRegistry();
|
2025-10-31 11:50:48 -04:00
|
|
|
}).toThrowWithMessage(TypeError, "FinalizationRegistry constructor must be called with 'new'");
|
2021-06-15 22:16:17 +03:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("normal behavior", () => {
|
|
|
|
|
test("typeof", () => {
|
|
|
|
|
expect(typeof new FinalizationRegistry(() => {})).toBe("object");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("constructor with single callback argument", () => {
|
|
|
|
|
var a = new FinalizationRegistry(() => {});
|
|
|
|
|
expect(a instanceof FinalizationRegistry).toBeTrue();
|
|
|
|
|
});
|
|
|
|
|
});
|