Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/tests/smoke/shortcodes/shortcodes-core.test.ts
12921 views
1
import { join } from "../../../src/deno_ral/path.ts";
2
3
import { docs, outputForInput } from "../../utils.ts";
4
import { ensureFileRegexMatches, noErrorsOrWarnings } from "../../verify.ts";
5
import { testRender } from "../render/render.ts";
6
7
const input = docs(join("shortcodes", "metadata.qmd"));
8
const output = outputForInput(input, "html");
9
testRender(input, "html", false, [
10
ensureFileRegexMatches(output.outputPath, [
11
/Subkey Value/,
12
/Hello World/,
13
], [
14
/\?meta/,
15
]),
16
]);
17
18
const inputCustom = docs(join("shortcodes", "custom.qmd"));
19
const outputCustom = outputForInput(inputCustom, "html");
20
testRender(inputCustom, "html", false, [
21
ensureFileRegexMatches(outputCustom.outputPath, [
22
/<strong>_bringit_<\/strong>/,
23
/\?shorty:error_args/,
24
/\?shorty:error message/,
25
], [
26
/\?shorty:_bringit_/,
27
]),
28
]);
29
30
const inputError = docs(join("shortcodes", "metadata-error.qmd"));
31
const outputError = outputForInput(inputError, "html");
32
testRender(inputError, "html", false, [
33
ensureFileRegexMatches(outputError.outputPath, [
34
/\?meta:equation/,
35
/\?invalid meta type:weird-type/,
36
]),
37
]);
38
39
const inputVars = docs(join("shortcodes", "vars-simple.qmd"));
40
const outputVars = outputForInput(inputVars, "html");
41
testRender(inputVars, "html", false, [
42
ensureFileRegexMatches(outputVars.outputPath, [
43
/bar/,
44
/Variable 2 Sub Sub VALUE/,
45
], [
46
/\?var/,
47
]),
48
]);
49
50
const inputVarsLinks = docs(join("shortcodes", "vars-links.qmd"));
51
const outputVarsLinks = outputForInput(inputVarsLinks, "html");
52
testRender(inputVarsLinks, "html", false, [
53
ensureFileRegexMatches(outputVarsLinks.outputPath, [
54
/http\:\/\/www\.test\.com\/bar/,
55
/images\/beach\.jpg\?bar/,
56
], []),
57
]);
58
59
const inputVarsErr = docs(join("shortcodes", "vars-error.qmd"));
60
const outputVarsErr = outputForInput(inputVarsErr, "html");
61
testRender(inputVarsErr, "html", false, [
62
ensureFileRegexMatches(outputVarsErr.outputPath, [
63
/\?var:foobar123/,
64
]),
65
]);
66
67
const inputNoVars = docs(join("shortcodes", "vars-simple.qmd"));
68
testRender(inputNoVars, "html", false, [
69
noErrorsOrWarnings,
70
], {
71
setup: async () => {
72
await Deno.rename(
73
docs(join("shortcodes", "_variables.yml")),
74
docs(join("shortcodes", "_variables.yml,bak")),
75
);
76
},
77
teardown: async () => {
78
await Deno.rename(
79
docs(join("shortcodes", "_variables.yml,bak")),
80
docs(join("shortcodes", "_variables.yml")),
81
);
82
},
83
});
84
85