Path: blob/main/tests/smoke/crossref/figures.test.ts
12921 views
/*1* figures.test.ts2*3* Copyright (C) 2020-2022 Posit Software, PBC4*/56import { ensureFileRegexMatches, ensureHtmlElements } from "../../verify.ts";7import { testRender } from "../render/render.ts";8import { crossref } from "./utils.ts";910const simpleQmd = crossref("simple.qmd", "html");11testRender(simpleQmd.input, "html", false, [12ensureHtmlElements(simpleQmd.output.outputPath, [13"section#simple-figure > h2",14"div#fig-elephant > figure > figcaption.quarto-float-fig.quarto-float-caption",15"section#simple-sub-figure > h2",16"section#simple-sub-figure > div.quarto-layout-panel > figure div.quarto-layout-row",17"section#simple-sub-figure > div.quarto-layout-panel > figure > figcaption.quarto-float-fig.quarto-float-caption",18]),19ensureFileRegexMatches(simpleQmd.output.outputPath, [20/Figure 1: Elephant/,21/Figure 2: Famous Elephants/,22/\(a\) Surus/,23/\(b\) Abbas/,24/Figure 1/,25/Figure 2/,26/Figure 2 \(b\)/,27], [28/\?@fig-/,29]),30]);3132const pythonQmd = crossref("python.qmd", "html");33testRender(pythonQmd.input, "html", false, [34ensureHtmlElements(pythonQmd.output.outputPath, [35"section#python-crossref-figure div#fig-plot > figure img.figure-img",36"section#python-crossref-figure div#fig-plot > figure > figcaption",37]),38ensureFileRegexMatches(pythonQmd.output.outputPath, [39/Figure 1: Plot/,40/Figure 1/,41], [42/\?@fig-/,43]),44]);4546const pythonSubfigQmd = crossref("python-subfig.qmd", "html");47testRender(pythonSubfigQmd.input, "html", false, [48ensureHtmlElements(pythonSubfigQmd.output.outputPath, [49"section#python-crossref-figure div.quarto-layout-panel > figure div.quarto-layout-row",50"section#python-crossref-figure div.quarto-layout-panel > figure > figcaption.quarto-float-fig.quarto-float-caption",51"section#python-crossref-figure div.quarto-layout-panel > figure img.figure-img",52]),53ensureFileRegexMatches(pythonSubfigQmd.output.outputPath, [54/Figure 1: Plots/,55/Figure 1/,56/Figure 1 \(b\)/,57/\(a\) Plot 1/,58/\(b\) Plot 2/,59], [60/\?@fig-/,61]),62]);6364for (const file of ["julia.qmd", "julianative.qmd"]) {65const juliaQmd = crossref(file, "html");66testRender(juliaQmd.input, "html", false, [67ensureHtmlElements(juliaQmd.output.outputPath, [68"section#julia-crossref-figure div#fig-plot > figure img.figure-img",69"section#julia-crossref-figure div#fig-plot > figure > figcaption",70]),71ensureFileRegexMatches(juliaQmd.output.outputPath, [72/Figure 1: Plot/,73/Figure 1/,74], [75/\?@fig-/,76]),77]);78}7980for (const file of ["julia-subfig.qmd", "julianative-subfig.qmd"]) {81const juliaSubfigQmd = crossref(file, "html");82testRender(juliaSubfigQmd.input, "html", false, [83ensureHtmlElements(juliaSubfigQmd.output.outputPath, [84"section#julia-crossref-figure div.quarto-layout-panel > figure div.quarto-layout-row",85"section#julia-crossref-figure div.quarto-layout-panel > figure > figcaption.quarto-float-fig.quarto-float-caption",86]),87ensureFileRegexMatches(juliaSubfigQmd.output.outputPath, [88/Figure 1: Plots/,89/Figure 1/,90/Figure 1 \(b\)/,91/\(a\) Plot 1/,92/\(b\) Plot 2/,93], [94/\?@fig-/,95]),96]);97}9899const knitrQmd = crossref("knitr.qmd", "html");100testRender(knitrQmd.input, "html", false, [101ensureHtmlElements(knitrQmd.output.outputPath, [102"section#knitr-crossref-figure div#fig-plot > figure img.figure-img",103"section#knitr-crossref-figure div#fig-plot > figure > figcaption",104]),105ensureFileRegexMatches(knitrQmd.output.outputPath, [106/Figure 1: Plot/,107/Figure 1/,108], [109/\?@fig-/,110]),111]);112113114