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