ShadowRealm.js 633 B

1234567891011121314151617181920
  1. describe("errors", () => {
  2. test("called without new", () => {
  3. expect(() => {
  4. ShadowRealm();
  5. }).toThrowWithMessage(TypeError, "ShadowRealm constructor must be called with 'new'");
  6. });
  7. });
  8. describe("normal behavior", () => {
  9. test("length is 0", () => {
  10. expect(ShadowRealm).toHaveLength(0);
  11. });
  12. test("basic functionality", () => {
  13. const shadowRealm = new ShadowRealm();
  14. expect(typeof shadowRealm).toBe("object");
  15. expect(shadowRealm).toBeInstanceOf(ShadowRealm);
  16. expect(Object.getPrototypeOf(shadowRealm)).toBe(ShadowRealm.prototype);
  17. });
  18. });