Path: blob/main/tests/smoke/crossref/tables.test.ts
12925 views
/*1* tables.test.ts2*3* Copyright (C) 2020-2022 Posit Software, PBC4*/56import { ensureFileRegexMatches, ensureHtmlElements } from "../../verify.ts";7import { renderVerifyLatexOutput, testRender } from "../render/render.ts";8import { crossref } from "./utils.ts";9import { docs } from "../../utils.ts";1011/* HTML */1213const tablesQmd = crossref("tables.qmd", "html");14testRender(tablesQmd.input, "html", false, [15ensureHtmlElements(tablesQmd.output.outputPath, [16// tables in figure elements17"section#simple-crossref-table > div#tbl-letters > figure table",18"section#sub-tables div.quarto-layout-panel > figure div.quarto-layout-row div#tbl-first > figure table",19"section#sub-tables div.quarto-layout-panel > figure div.quarto-layout-row div#tbl-second > figure table",2021// table captions in figure elements (with and without subfloats)22"section#simple-crossref-table > div#tbl-letters > figure.quarto-float-tbl > figcaption.quarto-float-tbl.quarto-float-caption",23"section#sub-tables div#tbl-panel.quarto-layout-panel > figure.quarto-float-tbl > figcaption.quarto-float-tbl.quarto-float-caption",24"section#sub-tables div.quarto-layout-panel div.quarto-layout-row div#tbl-first > figure.quarto-subfloat-tbl > figcaption.quarto-subfloat-tbl.quarto-subfloat-caption",25"section#sub-tables div.quarto-layout-panel div.quarto-layout-row div#tbl-second > figure.quarto-subfloat-tbl > figcaption.quarto-subfloat-tbl.quarto-subfloat-caption",26]),27ensureFileRegexMatches(tablesQmd.output.outputPath, [28/Table 1: My Caption/,29/Table 2: Main Caption/,30/Table 1/,31/Table 2/,32/Table 2 \(b\)/,33/\(a\) First Table/,34/\(b\) Second Table/,35], [36/\?@tbl-/,37]),38]);3940const knitrTablesQmd = crossref("knitr-tables.qmd", "html");41testRender(knitrTablesQmd.input, "html", false, [42ensureHtmlElements(knitrTablesQmd.output.outputPath, [43"div.quarto-layout-panel div.quarto-layout-row div#tbl-cars > figure.quarto-subfloat-tbl >figcaption.quarto-subfloat-tbl.quarto-subfloat-caption",44"div.quarto-layout-panel div.quarto-layout-row div#tbl-pressure > figure.quarto-subfloat-tbl > figcaption.quarto-subfloat-tbl.quarto-subfloat-caption",45]),46ensureFileRegexMatches(knitrTablesQmd.output.outputPath, [47/Table 1: Tables/,48/Table 1 \(a\)/,49/\(a\) Cars/,50/\(b\) Pressure/,51], [52/\?@tbl-/,53]),54]);5556/* LaTeX */5758/* caption is inserted in the right place in table environment*/59renderVerifyLatexOutput(docs("crossrefs/knitr-tables-latex.qmd"), [60/\\begin{longtable}\[.*\]{.*}.*\n+\\caption{\\label{tbl-1}.*}\n+.*\\tabularnewline/,61/\\begin{table}\n+\\caption{\\label{tbl-2}.*}.*\n+\\centering{?\n+\\begin{tabular}{.*}/,62/\\begin{longtable}{.*}.*\n+\\caption{\\label{tbl-3}.*}\n+.*\\tabularnewline/,63// two centering calls here is ugly, but we don't control the input we get64/\\begin{table}\n+\\caption{\\label{tbl-4}.*}.*\n+\\centering{?\n+\\centering\n+\\begin{tabular}\[c\]{.*}/,65]);666768