Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/tests/smoke/site/site.ts
6442 views
1
/*
2
* site.ts
3
*
4
* Copyright (C) 2020-2022 Posit Software, PBC
5
*/
6
import { existsSync } from "../../../src/deno_ral/fs.ts";
7
import { dirname } from "../../../src/deno_ral/path.ts";
8
import { testQuartoCmd, Verify, TestContext, mergeTestContexts } from "../../test.ts";
9
import { projectOutputForInput } from "../../utils.ts";
10
import { ensureHtmlElements, noErrorsOrWarnings } from "../../verify.ts";
11
12
export const testSite = (
13
input: string,
14
renderTarget: string,
15
includeSelectors: string[],
16
excludeSelectors: string[],
17
additionalContext?: TestContext,
18
...verify: Verify[]
19
) => {
20
const output = projectOutputForInput(input);
21
22
const verifySel = ensureHtmlElements(
23
output.outputPath,
24
includeSelectors,
25
excludeSelectors,
26
);
27
28
const baseContext: TestContext = {
29
teardown: async () => {
30
const siteDir = dirname(output.outputPath);
31
if (existsSync(siteDir)) {
32
await Deno.remove(siteDir, { recursive: true });
33
}
34
},
35
};
36
37
// Run the command
38
testQuartoCmd(
39
"render",
40
[renderTarget],
41
[noErrorsOrWarnings, verifySel, ...verify],
42
mergeTestContexts(baseContext, additionalContext),
43
);
44
};
45
46