Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/tests/smoke/crossref/thereoms.test.ts
12925 views
1
/*
2
* theorems.test.ts
3
*
4
* Copyright (C) 2020-2022 Posit Software, PBC
5
*
6
*/
7
8
import { ensureFileRegexMatches, ensureHtmlElements } from "../../verify.ts";
9
import { testRender } from "../render/render.ts";
10
11
import { crossref } from "./utils.ts";
12
13
const therQmd = crossref("theorems.qmd", "html");
14
testRender(therQmd.input, "html", false, [
15
ensureHtmlElements(therQmd.output.outputPath, [
16
"div#thm-line span.theorem-title",
17
]),
18
ensureFileRegexMatches(therQmd.output.outputPath, [
19
/Theorem 1/,
20
/Theorem 1 \(Line\)/,
21
], [
22
/\?@thm-/,
23
]),
24
]);
25
26
// Build the set of matches and no matches for the various types
27
const types = [
28
["Lemma", "lem"],
29
["Corollary", "cor"],
30
["Proposition", "prp"],
31
["Conjecture", "cnj"],
32
["Definition", "def"],
33
["Example", "exm"],
34
["Exercise", "exr"],
35
];
36
const selectors = types.map((type) => {
37
return `div#${type[1]}-test span.theorem-title`;
38
});
39
const matches: RegExp[] = [];
40
types.forEach((type) => {
41
matches.push(RegExp(`${type[0]} 1`));
42
matches.push(RegExp(`${type[0]} 1 \\(${type[0]}\\)`));
43
matches.push(RegExp(`${type[0]} 1`));
44
});
45
const noMatches = types.map((type) => {
46
return RegExp(`\\?${type[1]}-`);
47
});
48
49
const therTypesQmd = crossref("theorem-types.qmd", "html");
50
testRender(therTypesQmd.input, "html", false, [
51
ensureHtmlElements(therTypesQmd.output.outputPath, selectors),
52
ensureFileRegexMatches(therTypesQmd.output.outputPath, matches, noMatches),
53
]);
54
55