-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.ts
27 lines (26 loc) · 977 Bytes
/
index.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { handlebarsSpec, helpers } from "@handlebars-ng/specification";
import type { HandlebarsTest } from "@handlebars-ng/specification";
import { HandlebarsNgRunner } from ".";
describe("the runner runs templates from the spec", () => {
for (const [filename, testCase] of Object.entries<HandlebarsTest>(
handlebarsSpec,
)) {
if (testCase.type === "success") {
describe(filename, () => {
it(testCase.description, () => {
const runner = new HandlebarsNgRunner();
if (testCase.helpers != null) {
for (const [name, helper] of Object.entries(testCase.helpers)) {
if (helper in helpers) {
runner.registerHelper(name, helpers[helper].fn);
}
}
}
const compiledTemplate = runner.compile(testCase.ast);
const result = compiledTemplate(testCase.input);
expect(result).toEqual(testCase.output);
});
});
}
}
});