Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/tests/smoke/render/render-reveal.test.ts
12921 views
1
/*
2
* render-reveal.test.ts
3
*
4
* Copyright (C) 2020-2022 Posit Software, PBC
5
*/
6
7
import { docs, fileLoader, outputForInput } from "../../utils.ts";
8
import {
9
ensureFileRegexMatches,
10
ensureHtmlElements,
11
ensureHtmlSelectorSatisfies,
12
} from "../../verify.ts";
13
import { testRender } from "./render.ts";
14
15
// demo file renders ok
16
testRender(docs("reveal/index.qmd"), "revealjs", false);
17
18
let input = docs("reveal/aside-footnotes.qmd");
19
let output = outputForInput(input, "revealjs");
20
testRender(input, "revealjs", false, [
21
ensureHtmlElements(output.outputPath, [
22
// speaker notes are left not moved
23
"section#slide-with-speaker-notes > aside.notes:last-child",
24
// div of class aside are moved
25
"section#slide-with-footnotes > aside:last-child > div > p",
26
// footnotes are put in aside
27
"section#slide-with-footnotes > aside:last-child > ol.aside-footnotes > li",
28
], [
29
// footnotes back are removed
30
"section#slide-with-footnotes > aside:last-child > ol.aside-footnotes > li > .footnote-back",
31
]),
32
]);
33
34
// auto-stretch feature
35
input = docs("reveal/stretch.qmd");
36
output = outputForInput(input, "revealjs");
37
testRender(input, "revealjs", false, [
38
ensureHtmlElements(output.outputPath, [
39
"#simple-image > p + img.r-stretch",
40
"#chunk-below > p + img.r-stretch + p.caption + div.cell",
41
"#no-caption > p + img.r-stretch",
42
"#height-defined img:not(.r-stretch)",
43
"#rigth-aligned > img.r-stretch.quarto-figure-right",
44
"#only-image > img.r-stretch + p.caption",
45
"#alt-text > img.r-stretch[alt]",
46
"#caption-title > img.r-stretch[title] + p.caption",
47
"#with-class-no-caption > img.stretch",
48
"#with-class-caption > img.stretch.quarto-figure-center + p.caption",
49
"#knitr-plot > div.cell + img.r-stretch + p.caption",
50
"#knitr-plot-no-echo > img.r-stretch + p.caption",
51
"#knitr-and-text > img.r-stretch + p.caption + p",
52
"#knitr-align > img.r-stretch.quarto-figure-right + p.caption",
53
"#knitr-no-caption-and-content > img.r-stretch ~ div.cell",
54
"#no-content > img.r-stretch",
55
"#no-content-caption > img.r-stretch + p.caption",
56
"#custom-divs-opt-in > div.custom-block:not(.r-stretch) + img.r-stretch + p.caption",
57
], [
58
"#columns img.r-stretch",
59
"#more-than-one img.r-stretch",
60
"section#no-stretch-class.nostretch img.r-stretch",
61
"#knitr-height img.r-stretch",
62
"#knitr-height-pct img.r-stretch",
63
"#inline-image img.r-stretch",
64
"#block-layout img.r-stretch",
65
"#block-layout2 img.r-stretch",
66
"#fig-tab-layout img.r-stretch",
67
"#custom-divs-simple img.r-stretch",
68
"#custom-divs-caption img.r-stretch",
69
"#custom-divs-caption img.r-stretch",
70
"#custom-divs-knitr img.r-stretch",
71
"#custom-divs-knitr-caption img.r-stretch",
72
"#aside img.r-stretch",
73
"#absolute img.r-stretch",
74
"#link img.r-stretch",
75
]),
76
]);
77
78
// fragments
79
const fragmentsDiv = fileLoader("reveal")("fragments.qmd", "revealjs");
80
testRender(fragmentsDiv.input, "revealjs", false, [
81
ensureHtmlElements(fragmentsDiv.output.outputPath, [
82
"#slide-2 > div.fragment > h3",
83
], []),
84
]);
85
86
// output-location
87
const outputLocation = fileLoader("reveal")("output-location.qmd", "revealjs");
88
testRender(outputLocation.input, "revealjs", false, [
89
ensureHtmlElements(outputLocation.output.outputPath, [
90
"section#loc-slide + section#loc-slide-output > div.output-location-slide",
91
"section#loc-fragment > div.fragment > div.cell-output-display",
92
"section#loc-col-fragment > div.columns > div.column:nth-child(2).fragment > div.cell-output-display",
93
], [
94
"section#loc-slide > div.output-location-slide",
95
]),
96
ensureHtmlSelectorSatisfies(
97
outputLocation.output.outputPath,
98
"section#loc-column > div.columns > div.column",
99
(nodeList) => {
100
return nodeList.length === 2;
101
},
102
),
103
ensureHtmlSelectorSatisfies(
104
outputLocation.output.outputPath,
105
"section#loc-col-fragment > div.columns > div.column",
106
(nodeList) => {
107
return nodeList.length === 2;
108
},
109
),
110
]);
111
112
// reveal-config
113
const revealConfigs = fileLoader("reveal")("reveal-configs.qmd", "revealjs");
114
testRender(revealConfigs.input, "revealjs", false, [
115
ensureFileRegexMatches(revealConfigs.output.outputPath, [
116
"pdfSeparateFragments.*true",
117
"smaller.*true",
118
"pdfSeparateFragments.*true",
119
'autoAnimateEasing.*"ease-in-out"',
120
"autoAnimateDuration.*5",
121
"autoAnimateUnmatched.*false",
122
"pdfMaxPagesPerSlide.*1",
123
], []),
124
]);
125
126