• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import * as fs from 'node:fs';
2import * as path from 'node:path';
3import { normalizeNewLine } from './common.js';
4
5export function loadSAXParserTestData(): { name: string; src: string; expected: string }[] {
6    const dataDirPath = new URL('../data/sax', import.meta.url);
7    const testSetFileDirs = fs.readdirSync(dataDirPath);
8
9    return testSetFileDirs.map((dirName) => {
10        const srcFilePath = path.join(dataDirPath.pathname, dirName, 'src.html');
11        const expectedFilePath = path.join(dataDirPath.pathname, dirName, 'expected.html');
12        const src = fs.readFileSync(srcFilePath).toString();
13        const expected = fs.readFileSync(expectedFilePath).toString();
14
15        return {
16            name: dirName,
17            src: normalizeNewLine(src),
18            expected: normalizeNewLine(expected),
19        };
20    });
21}
22