Path: blob/main/tests/smoke/site/render-site-themes.test.ts
6453 views
/*1* render-site.test.ts2*3* Copyright (C) 2020-2022 Posit Software, PBC4*5*/67import { copySync } from "../../../src/deno_ral/fs.ts";8import { join } from "../../../src/deno_ral/path.ts";9import { testQuartoCmd, Verify } from "../../test.ts";10import { docs } from "../../utils.ts";11import { fileExists, noErrorsOrWarnings } from "../../verify.ts";1213const kThemes = [14"",15"none",16"pandoc",17"cerulean",18"cosmo",19"cyborg",20"darkly",21"flatly",22"journal",23"litera",24"lumen",25"lux",26"materia",27"minty",28"morph",29"pulse",30"quartz",31"sandstone",32"simplex",33"sketchy",34"slate",35"solar",36"spacelab",37"superhero",38"united",39"vapor",40"yeti",41"zephyr",42];4344const workingDir = Deno.makeTempDirSync();45try {46kThemes.forEach((theme) => {47const path = join(workingDir, `site-themes-${theme}`);48const outputFile = join(path, "_site", "index.html");49const verify: Verify[] = [noErrorsOrWarnings, fileExists(outputFile)];5051// Run the command52testQuartoCmd(53"render",54[55join(path, "index.qmd"),56"--to",57"html",58],59verify,60{61setup: () => {62// Copy to a temp dir63copySync(docs("site-themes"), path);6465// modify the quarto.yaml file to have the theme we want66const qYamlFile = join(path, "_quarto.yml");67const qYaml = Deno.readTextFileSync(qYamlFile);68const updatedYaml = qYaml.replace(69/theme: none/,70theme !== "" ? `theme: ${theme}` : "",71);7273Deno.writeTextFileSync(qYamlFile, updatedYaml);74return Promise.resolve();75},76teardown: () => {77// clean output78Deno.removeSync(path, { recursive: true });79return Promise.resolve();80},81},82);83});84} finally {85Deno.removeSync(workingDir);86}878889