Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/tests/unit/schema-validation/error-location.test.ts
6451 views
1
/*
2
* error-location.test.ts
3
*
4
* Copyright (C) 2021-2022 Posit Software, PBC
5
*
6
*/
7
8
import { unitTest } from "../../test.ts";
9
10
//import { schemaTestFile } from "./utils.ts";
11
//import { cleanoutput } from "../../smoke/render/render.ts";
12
//import { validateDocumentFromSource } from "../../../src/core/schema/validate-document.ts";
13
14
unitTest("schema-validation-error-location", async () => {
15
/*
16
FIXME: we're temporarily disabling this test since it relies on format
17
checks failing, and our format schema is disabled on `main` to avoid
18
user breakage at the moment.
19
20
const {
21
input
22
} = schemaTestFile("good-validation-fail.qmd", "html");
23
24
const src = Deno.readTextFileSync(input);
25
const ignore = (_foo: string) => {};
26
const errors = await validateDocumentFromSource(src, ignore, ignore);
27
28
// check that it found all bad instances
29
const badInstancesGroundTruth = ["/format/html/dpi", "/echo"];
30
assert(errors.length === 2);
31
const badInstancesSeen = errors.map(error => error.instancePath);
32
assert(badInstancesSeen.every(seen => badInstancesGroundTruth.indexOf(seen) !== -1));
33
34
// check that the instances are reported in the right location
35
const error1 = errors.filter(error => error.instancePath === "/format/html/dpi")[0];
36
const error2 = errors.filter(error => error.instancePath === "/echo")[0];
37
38
// lines and columns are zero-based
39
assert(error1.start!.line === 4);
40
assert(error1.start!.column === 9);
41
assert(error1.end!.line === 4);
42
assert(error1.end!.column === 15);
43
44
assert(error2.start!.line === 8);
45
assert(error2.start!.column === 9);
46
assert(error2.end!.line === 8);
47
assert(error2.end!.column === 15);
48
49
cleanoutput("good-validation-fail.qmd", "html");
50
*/
51
});
52
53