2020-07-04 15:42:19 +01:00
|
|
|
test("length is 1", () => {
|
2020-07-05 09:27:00 -07:00
|
|
|
expect(Reflect.isExtensible).toHaveLength(1);
|
2020-07-04 15:42:19 +01:00
|
|
|
});
|
2020-06-02 12:36:11 +01:00
|
|
|
|
2020-07-04 15:42:19 +01:00
|
|
|
describe("errors", () => {
|
2020-07-05 09:27:00 -07:00
|
|
|
test("target must be an object", () => {
|
|
|
|
|
[null, undefined, "foo", 123, NaN, Infinity].forEach(value => {
|
|
|
|
|
expect(() => {
|
|
|
|
|
Reflect.isExtensible(value);
|
|
|
|
|
}).toThrowWithMessage(
|
|
|
|
|
TypeError,
|
|
|
|
|
"First argument of Reflect.isExtensible() must be an object"
|
|
|
|
|
);
|
2020-06-02 12:36:11 +01:00
|
|
|
});
|
2020-07-05 09:27:00 -07:00
|
|
|
});
|
2020-07-04 15:42:19 +01:00
|
|
|
});
|
2020-06-02 12:36:11 +01:00
|
|
|
|
2020-07-04 15:42:19 +01:00
|
|
|
describe("normal behavior", () => {
|
2020-07-05 09:27:00 -07:00
|
|
|
test("regular object is extensible", () => {
|
|
|
|
|
expect(Reflect.isExtensible({})).toBeTrue();
|
|
|
|
|
});
|
2020-06-02 12:36:11 +01:00
|
|
|
|
2020-07-05 09:27:00 -07:00
|
|
|
test("global object is extensible", () => {
|
|
|
|
|
expect(Reflect.isExtensible(globalThis)).toBeTrue();
|
|
|
|
|
});
|
2020-06-02 12:36:11 +01:00
|
|
|
|
2020-07-05 09:27:00 -07:00
|
|
|
test("regular object is not extensible after preventExtensions()", () => {
|
|
|
|
|
var o = {};
|
|
|
|
|
expect(Reflect.isExtensible(o)).toBeTrue();
|
|
|
|
|
Reflect.preventExtensions(o);
|
|
|
|
|
expect(Reflect.isExtensible(o)).toBeFalse();
|
|
|
|
|
});
|
2020-07-04 15:42:19 +01:00
|
|
|
});
|