Path: blob/main/tests/smoke/crossref/thereoms.test.ts
12925 views
/*1* theorems.test.ts2*3* Copyright (C) 2020-2022 Posit Software, PBC4*5*/67import { ensureFileRegexMatches, ensureHtmlElements } from "../../verify.ts";8import { testRender } from "../render/render.ts";910import { crossref } from "./utils.ts";1112const therQmd = crossref("theorems.qmd", "html");13testRender(therQmd.input, "html", false, [14ensureHtmlElements(therQmd.output.outputPath, [15"div#thm-line span.theorem-title",16]),17ensureFileRegexMatches(therQmd.output.outputPath, [18/Theorem 1/,19/Theorem 1 \(Line\)/,20], [21/\?@thm-/,22]),23]);2425// Build the set of matches and no matches for the various types26const types = [27["Lemma", "lem"],28["Corollary", "cor"],29["Proposition", "prp"],30["Conjecture", "cnj"],31["Definition", "def"],32["Example", "exm"],33["Exercise", "exr"],34];35const selectors = types.map((type) => {36return `div#${type[1]}-test span.theorem-title`;37});38const matches: RegExp[] = [];39types.forEach((type) => {40matches.push(RegExp(`${type[0]} 1`));41matches.push(RegExp(`${type[0]} 1 \\(${type[0]}\\)`));42matches.push(RegExp(`${type[0]} 1`));43});44const noMatches = types.map((type) => {45return RegExp(`\\?${type[1]}-`);46});4748const therTypesQmd = crossref("theorem-types.qmd", "html");49testRender(therTypesQmd.input, "html", false, [50ensureHtmlElements(therTypesQmd.output.outputPath, selectors),51ensureFileRegexMatches(therTypesQmd.output.outputPath, matches, noMatches),52]);535455