Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/tests/smoke/site/render-site-themes.test.ts
6453 views
1
/*
2
* render-site.test.ts
3
*
4
* Copyright (C) 2020-2022 Posit Software, PBC
5
*
6
*/
7
8
import { copySync } from "../../../src/deno_ral/fs.ts";
9
import { join } from "../../../src/deno_ral/path.ts";
10
import { testQuartoCmd, Verify } from "../../test.ts";
11
import { docs } from "../../utils.ts";
12
import { fileExists, noErrorsOrWarnings } from "../../verify.ts";
13
14
const kThemes = [
15
"",
16
"none",
17
"pandoc",
18
"cerulean",
19
"cosmo",
20
"cyborg",
21
"darkly",
22
"flatly",
23
"journal",
24
"litera",
25
"lumen",
26
"lux",
27
"materia",
28
"minty",
29
"morph",
30
"pulse",
31
"quartz",
32
"sandstone",
33
"simplex",
34
"sketchy",
35
"slate",
36
"solar",
37
"spacelab",
38
"superhero",
39
"united",
40
"vapor",
41
"yeti",
42
"zephyr",
43
];
44
45
const workingDir = Deno.makeTempDirSync();
46
try {
47
kThemes.forEach((theme) => {
48
const path = join(workingDir, `site-themes-${theme}`);
49
const outputFile = join(path, "_site", "index.html");
50
const verify: Verify[] = [noErrorsOrWarnings, fileExists(outputFile)];
51
52
// Run the command
53
testQuartoCmd(
54
"render",
55
[
56
join(path, "index.qmd"),
57
"--to",
58
"html",
59
],
60
verify,
61
{
62
setup: () => {
63
// Copy to a temp dir
64
copySync(docs("site-themes"), path);
65
66
// modify the quarto.yaml file to have the theme we want
67
const qYamlFile = join(path, "_quarto.yml");
68
const qYaml = Deno.readTextFileSync(qYamlFile);
69
const updatedYaml = qYaml.replace(
70
/theme: none/,
71
theme !== "" ? `theme: ${theme}` : "",
72
);
73
74
Deno.writeTextFileSync(qYamlFile, updatedYaml);
75
return Promise.resolve();
76
},
77
teardown: () => {
78
// clean output
79
Deno.removeSync(path, { recursive: true });
80
return Promise.resolve();
81
},
82
},
83
);
84
});
85
} finally {
86
Deno.removeSync(workingDir);
87
}
88
89