|
|
|
@ -17,7 +17,10 @@ describe("validate", () => {
|
|
|
|
|
(solo ? it.only : skip ? it.skip : it)(dir, () => {
|
|
|
|
|
const config = loadConfig(`./validator/samples/${dir}/_config.js`);
|
|
|
|
|
|
|
|
|
|
function test(input, expectedWarnings, expectedErrors) {
|
|
|
|
|
const input = fs.readFileSync(`test/validator/samples/${dir}/input.html`, "utf-8").replace(/\s+$/, "");
|
|
|
|
|
const expectedWarnings = tryToLoadJson(`test/validator/samples/${dir}/warnings.json`) || [];
|
|
|
|
|
const expectedErrors = tryToLoadJson(`test/validator/samples/${dir}/errors.json`);
|
|
|
|
|
|
|
|
|
|
let error;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
@ -29,7 +32,8 @@ describe("validate", () => {
|
|
|
|
|
warnings.push({ code, message, pos, loc, end });
|
|
|
|
|
},
|
|
|
|
|
dev: config.dev,
|
|
|
|
|
generate: false
|
|
|
|
|
generate: false,
|
|
|
|
|
parser: 'v2' // TODO remove
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
assert.equal(stats.warnings.length, warnings.length);
|
|
|
|
@ -66,22 +70,6 @@ describe("validate", () => {
|
|
|
|
|
assert.deepEqual(error.end, expected.end);
|
|
|
|
|
assert.equal(error.pos, expected.pos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO remove the v1 tests
|
|
|
|
|
test(
|
|
|
|
|
fs.readFileSync(`test/validator/samples/${dir}/input.html`, "utf-8").replace(/\s+$/, ""),
|
|
|
|
|
tryToLoadJson(`test/validator/samples/${dir}/warnings.json`) || [],
|
|
|
|
|
tryToLoadJson(`test/validator/samples/${dir}/errors.json`)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (fs.existsSync(`test/validator/samples/${dir}/input-v2.html`)) {
|
|
|
|
|
test(
|
|
|
|
|
fs.readFileSync(`test/validator/samples/${dir}/input-v2.html`, "utf-8").replace(/\s+$/, ""),
|
|
|
|
|
tryToLoadJson(`test/validator/samples/${dir}/warnings-v2.json`) || [],
|
|
|
|
|
tryToLoadJson(`test/validator/samples/${dir}/errors-v2.json`)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|