Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/tests/smoke/extensions/extension-render-project.test.ts
12925 views
1
/*
2
* extension-render-project.test.ts
3
*
4
* Copyright (C) 2020-2022 Posit Software, PBC
5
*/
6
7
import { docs, projectOutputForInput } from "../../utils.ts";
8
9
import { basename, dirname, extname, join, relative } from "../../../src/deno_ral/path.ts";
10
import { ensureHtmlElements } from "../../verify.ts";
11
import { testQuartoCmd } from "../../test.ts";
12
import { noErrors } from "../../verify.ts";
13
import { existsSync } from "../../../src/deno_ral/fs.ts";
14
15
const testRender = (
16
input: string,
17
includeSelectors: string[],
18
excludeSelectors: string[],
19
) => {
20
const output = projectOutputForInput(input);
21
const verifySel = ensureHtmlElements(
22
output.outputPath,
23
includeSelectors,
24
excludeSelectors,
25
);
26
27
// Run the command
28
testQuartoCmd(
29
"render",
30
[input],
31
[noErrors, verifySel],
32
{
33
teardown: async () => {
34
const siteDir = dirname(output.supportPath);
35
if (existsSync(siteDir)) {
36
await Deno.remove(siteDir, { recursive: true });
37
}
38
},
39
},
40
);
41
};
42
43
// The site root dir
44
const rootDir = docs("extensions/project/");
45
46
// Render the home page and verify the output
47
// contains the extension shortcodes and filter elements
48
testRender(join(rootDir, "posts/welcome/index.qmd"), [
49
"a.lightbox",
50
"i.fa-solid.fa-anchor",
51
"i.fa-solid.fa-bacteria",
52
"i.fa-solid.fa-jet-fighter",
53
], []);
54
55
// Render the welcome page (subdirectory) and verify the output
56
// contains the extension shortcodes and filter elements
57
const subdirInput = join(rootDir, "posts/welcome/index.qmd");
58
testRender(join(rootDir, "posts/welcome/index.qmd"), [
59
"a.lightbox",
60
"i.fa-solid.fa-anchor",
61
"i.fa-solid.fa-bacteria",
62
"i.fa-solid.fa-jet-fighter",
63
], []);
64
65