Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/tests/unit/config/format.test.ts
6451 views
1
/*
2
* format.test.ts
3
*
4
* Unit tests for format detection functions in src/config/format.ts
5
*/
6
7
import { unitTest } from "../../test.ts";
8
import { assert } from "testing/asserts";
9
10
import {
11
isTypstOutput,
12
isLatexOutput,
13
isPdfOutput,
14
isHtmlDocOutput,
15
isBeamerOutput,
16
isEpubOutput,
17
isDocxOutput,
18
isHtmlSlideOutput,
19
isHtmlDashboardOutput,
20
} from "../../../src/config/format.ts";
21
22
23
unitTest("format-detection - isTypstOutput with base format", async () => {
24
assert(isTypstOutput("typst") === true);
25
assert(isTypstOutput({ to: "typst" }) === true);
26
});
27
28
unitTest("format-detection - isTypstOutput with variants (CURRENTLY FAILS)", async () => {
29
assert(isTypstOutput("typst-citations") === true);
30
assert(isTypstOutput("typst+custom") === true);
31
assert(isTypstOutput({ to: "typst-citations" }) === true);
32
});
33
34
unitTest("format-detection - isTypstOutput negative cases", async () => {
35
assert(isTypstOutput("pdf") === false);
36
assert(isTypstOutput("latex") === false);
37
assert(isTypstOutput({ to: "html" }) === false);
38
});
39
40
unitTest("format-detection - isLatexOutput with base formats", async () => {
41
assert(isLatexOutput({ to: "latex" }) === true);
42
assert(isLatexOutput({ to: "pdf" }) === true);
43
assert(isLatexOutput({ to: "beamer" }) === true);
44
});
45
46
unitTest("format-detection - isLatexOutput with variants", async () => {
47
assert(isLatexOutput({ to: "latex-citations" }) === true);
48
assert(isLatexOutput({ to: "pdf+smart" }) === true);
49
assert(isLatexOutput({ to: "beamer-citations" }) === true);
50
});
51
52
unitTest("format-detection - isLatexOutput negative cases", async () => {
53
assert(isLatexOutput({ to: "html" }) === false);
54
assert(isLatexOutput({ to: "typst" }) === false);
55
});
56
57
unitTest("format-detection - isHtmlDocOutput with base formats", async () => {
58
assert(isHtmlDocOutput("html") === true);
59
assert(isHtmlDocOutput("html4") === true);
60
assert(isHtmlDocOutput("html5") === true);
61
assert(isHtmlDocOutput({ to: "html" }) === true);
62
});
63
64
unitTest("format-detection - isHtmlDocOutput with variants", async () => {
65
assert(isHtmlDocOutput("html-citations") === true);
66
assert(isHtmlDocOutput("html5+smart") === true);
67
assert(isHtmlDocOutput({ to: "html+citations" }) === true);
68
});
69
70
unitTest("format-detection - isHtmlDocOutput negative cases", async () => {
71
assert(isHtmlDocOutput("revealjs") === false);
72
assert(isHtmlDocOutput("pdf") === false);
73
assert(isHtmlDocOutput({ to: "typst" }) === false);
74
});
75
76
unitTest("format-detection - isPdfOutput with base formats", async () => {
77
assert(isPdfOutput("pdf") === true);
78
assert(isPdfOutput("beamer") === true);
79
assert(isPdfOutput({ to: "pdf" }) === true);
80
assert(isPdfOutput({ to: "beamer" }) === true);
81
});
82
83
unitTest("format-detection - isPdfOutput with variants", async () => {
84
assert(isPdfOutput("pdf-citations") === true);
85
assert(isPdfOutput("beamer+smart") === true);
86
assert(isPdfOutput({ to: "pdf+variant" }) === true);
87
});
88
89
unitTest("format-detection - isPdfOutput negative cases", async () => {
90
assert(isPdfOutput("html") === false);
91
assert(isPdfOutput("typst") === false);
92
assert(isPdfOutput({ to: "latex" }) === false);
93
});
94
95
unitTest("format-detection - isBeamerOutput with base format", async () => {
96
assert(isBeamerOutput({ to: "beamer" }) === true);
97
});
98
99
unitTest("format-detection - isBeamerOutput with variants", async () => {
100
assert(isBeamerOutput({ to: "beamer-citations" }) === true);
101
assert(isBeamerOutput({ to: "beamer+smart" }) === true);
102
});
103
104
unitTest("format-detection - isEpubOutput with base formats", async () => {
105
assert(isEpubOutput("epub") === true);
106
assert(isEpubOutput("epub2") === true);
107
assert(isEpubOutput("epub3") === true);
108
});
109
110
unitTest("format-detection - isEpubOutput with variants", async () => {
111
assert(isEpubOutput("epub+citations") === true);
112
assert(isEpubOutput({ to: "epub3+smart" }) === true);
113
});
114
115
unitTest("format-detection - isDocxOutput with base format", async () => {
116
assert(isDocxOutput("docx") === true);
117
assert(isDocxOutput({ to: "docx" }) === true);
118
});
119
120
unitTest("format-detection - isDocxOutput with variants", async () => {
121
assert(isDocxOutput("docx+citations") === true);
122
assert(isDocxOutput({ to: "docx+smart" }) === true);
123
});
124
125
unitTest("format-detection - isHtmlSlideOutput with base formats", async () => {
126
assert(isHtmlSlideOutput("revealjs") === true);
127
assert(isHtmlSlideOutput("slidy") === true);
128
assert(isHtmlSlideOutput({ to: "revealjs" }) === true);
129
});
130
131
unitTest("format-detection - isHtmlSlideOutput with variants", async () => {
132
assert(isHtmlSlideOutput("revealjs-citations") === true);
133
assert(isHtmlSlideOutput({ to: "slidy+smart" }) === true);
134
});
135
136
unitTest("format-detection - isHtmlDashboardOutput with base format", async () => {
137
assert(isHtmlDashboardOutput("dashboard") === true);
138
});
139
140
unitTest("format-detection - isHtmlDashboardOutput with custom suffix", async () => {
141
assert(isHtmlDashboardOutput("my-dashboard") === true);
142
assert(isHtmlDashboardOutput("custom-dashboard") === true);
143
});
144
145