asserts.js 613 B

12345678910111213141516171819202122232425262728
  1. import * as t from "../lib";
  2. describe("asserts", () => {
  3. const consoleTrace = console.trace;
  4. beforeEach(() => {
  5. console.trace = () => {};
  6. });
  7. afterEach(() => {
  8. console.trace = consoleTrace;
  9. });
  10. Object.keys(t).forEach(k => {
  11. if (k.startsWith("assert") && k !== "assertNode") {
  12. const nodeType = k.replace("assert", "");
  13. it(nodeType, () => {
  14. expect(() => {
  15. t[k]({ type: "FlavorTownDeclaration" }, {});
  16. }).toThrow(
  17. `Expected type "${nodeType}" with option {}, but instead got "FlavorTownDeclaration".`,
  18. );
  19. });
  20. }
  21. });
  22. });