Reflect.isExtensible.js 997 B

123456789101112131415161718192021222324252627282930313233
  1. test("length is 1", () => {
  2. expect(Reflect.isExtensible).toHaveLength(1);
  3. });
  4. describe("errors", () => {
  5. test("target must be an object", () => {
  6. [null, undefined, "foo", 123, NaN, Infinity].forEach(value => {
  7. expect(() => {
  8. Reflect.isExtensible(value);
  9. }).toThrowWithMessage(
  10. TypeError,
  11. "First argument of Reflect.isExtensible() must be an object"
  12. );
  13. });
  14. });
  15. });
  16. describe("normal behavior", () => {
  17. test("regular object is extensible", () => {
  18. expect(Reflect.isExtensible({})).toBeTrue();
  19. });
  20. test("global object is extensible", () => {
  21. expect(Reflect.isExtensible(globalThis)).toBeTrue();
  22. });
  23. test("regular object is not extensible after preventExtensions()", () => {
  24. var o = {};
  25. expect(Reflect.isExtensible(o)).toBeTrue();
  26. Reflect.preventExtensions(o);
  27. expect(Reflect.isExtensible(o)).toBeFalse();
  28. });
  29. });