-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathparsing.test.ts
More file actions
28 lines (27 loc) · 853 Bytes
/
parsing.test.ts
File metadata and controls
28 lines (27 loc) · 853 Bytes
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
28
import fs from "node:fs";
import path from "node:path";
// parse all fixture and should has
import { test } from "@textlint/ast-tester";
import { describe, expect, it } from "vitest";
import { convertTypstSourceToTextlintAstObject } from "../../src/typstToTextlintAst";
describe("parsing", () => {
const fixtureDir = path.join(__dirname, "fixtures");
for (const filePath of fs.readdirSync(fixtureDir)) {
const dirName = path.basename(filePath);
it(`${dirName} match AST`, async () => {
const input = fs.readFileSync(
path.join(fixtureDir, filePath, "input.typ"),
"utf-8",
);
const AST = await convertTypstSourceToTextlintAstObject(input);
test(AST);
const output = JSON.parse(
fs.readFileSync(
path.join(fixtureDir, filePath, "output.json"),
"utf-8",
),
);
expect(AST).toEqual(output);
});
}
});