Error.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. describe("normal behavior", () => {
  2. test("length is 1", () => {
  3. expect(Error).toHaveLength(1);
  4. expect(EvalError).toHaveLength(1);
  5. expect(RangeError).toHaveLength(1);
  6. expect(ReferenceError).toHaveLength(1);
  7. expect(SyntaxError).toHaveLength(1);
  8. expect(TypeError).toHaveLength(1);
  9. });
  10. test("name matches constructor name", () => {
  11. expect(Error.name).toBe("Error");
  12. expect(EvalError.name).toBe("EvalError");
  13. expect(RangeError.name).toBe("RangeError");
  14. expect(ReferenceError.name).toBe("ReferenceError");
  15. expect(SyntaxError.name).toBe("SyntaxError");
  16. expect(TypeError.name).toBe("TypeError");
  17. });
  18. test("basic functionality", () => {
  19. expect(Error()).toBeInstanceOf(Error);
  20. expect(new Error()).toBeInstanceOf(Error);
  21. expect(EvalError()).toBeInstanceOf(EvalError);
  22. expect(new EvalError()).toBeInstanceOf(EvalError);
  23. expect(RangeError()).toBeInstanceOf(RangeError);
  24. expect(new RangeError()).toBeInstanceOf(RangeError);
  25. expect(ReferenceError()).toBeInstanceOf(ReferenceError);
  26. expect(new ReferenceError()).toBeInstanceOf(ReferenceError);
  27. expect(SyntaxError()).toBeInstanceOf(SyntaxError);
  28. expect(new SyntaxError()).toBeInstanceOf(SyntaxError);
  29. expect(TypeError()).toBeInstanceOf(TypeError);
  30. expect(new TypeError()).toBeInstanceOf(TypeError);
  31. });
  32. });