1const fs = require('fs'); 2const path = require('path'); 3const { normalizeNewLine } = require('./common'); 4 5module.exports = function loadSAXParserTestData() { 6 const dataDirPath = path.join(__dirname, '../data/sax'); 7 const testSetFileDirs = fs.readdirSync(dataDirPath); 8 const tests = []; 9 10 testSetFileDirs.forEach(dirName => { 11 const srcFilePath = path.join(dataDirPath, dirName, 'src.html'); 12 const expectedFilePath = path.join(dataDirPath, dirName, 'expected.html'); 13 const src = fs.readFileSync(srcFilePath).toString(); 14 const expected = fs.readFileSync(expectedFilePath).toString(); 15 16 tests.push({ 17 name: dirName, 18 src: normalizeNewLine(src), 19 expected: normalizeNewLine(expected) 20 }); 21 }); 22 23 return tests; 24}; 25