Skip to content

Commit 5f22761

Browse files
committed
Migrate copy theme default fonts to BookTest
1 parent 0274ad6 commit 5f22761

File tree

2 files changed

+47
-25
lines changed

2 files changed

+47
-25
lines changed

tests/rendered_output.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -309,22 +309,6 @@ fn summary_with_markdown_formatting() {
309309
#[test]
310310
fn custom_fonts() {
311311
// Tests to ensure custom fonts are copied as expected.
312-
let builtin_fonts = [
313-
"OPEN-SANS-LICENSE.txt",
314-
"SOURCE-CODE-PRO-LICENSE.txt",
315-
"fonts.css",
316-
"open-sans-v17-all-charsets-300.woff2",
317-
"open-sans-v17-all-charsets-300italic.woff2",
318-
"open-sans-v17-all-charsets-600.woff2",
319-
"open-sans-v17-all-charsets-600italic.woff2",
320-
"open-sans-v17-all-charsets-700.woff2",
321-
"open-sans-v17-all-charsets-700italic.woff2",
322-
"open-sans-v17-all-charsets-800.woff2",
323-
"open-sans-v17-all-charsets-800italic.woff2",
324-
"open-sans-v17-all-charsets-italic.woff2",
325-
"open-sans-v17-all-charsets-regular.woff2",
326-
"source-code-pro-v11-all-charsets-500.woff2",
327-
];
328312
let actual_files = |path: &Path| -> Vec<String> {
329313
let mut actual: Vec<_> = path
330314
.read_dir()
@@ -339,15 +323,6 @@ fn custom_fonts() {
339323
contents.contains("fonts/fonts.css")
340324
};
341325

342-
// Full theme.
343-
let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap();
344-
let p = temp.path();
345-
MDBook::init(p).copy_theme(true).build().unwrap();
346-
assert_eq!(actual_files(&p.join("theme/fonts")), &builtin_fonts);
347-
MDBook::load(p).unwrap().build().unwrap();
348-
assert_eq!(actual_files(&p.join("book/fonts")), &builtin_fonts);
349-
assert!(has_fonts_css(p));
350-
351326
// Mixed with copy-fonts=true
352327
// Should ignore the copy-fonts setting since the user has provided their own fonts.css.
353328
let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap();

tests/testsuite/theme.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,50 @@ book/fonts/source-code-pro-v11-all-charsets-500.woff2
6868
"#]],
6969
);
7070
}
71+
72+
// When the theme is initialized, what does the fonts list look like?
73+
#[test]
74+
fn theme_fonts_copied() {
75+
BookTest::init(|bb| {
76+
bb.copy_theme(true);
77+
})
78+
.check_file_contains("book/index.html", "fonts/fonts.css")
79+
.check_file_list(
80+
"theme/fonts",
81+
str![[r#"
82+
theme/fonts/OPEN-SANS-LICENSE.txt
83+
theme/fonts/SOURCE-CODE-PRO-LICENSE.txt
84+
theme/fonts/fonts.css
85+
theme/fonts/open-sans-v17-all-charsets-300.woff2
86+
theme/fonts/open-sans-v17-all-charsets-300italic.woff2
87+
theme/fonts/open-sans-v17-all-charsets-600.woff2
88+
theme/fonts/open-sans-v17-all-charsets-600italic.woff2
89+
theme/fonts/open-sans-v17-all-charsets-700.woff2
90+
theme/fonts/open-sans-v17-all-charsets-700italic.woff2
91+
theme/fonts/open-sans-v17-all-charsets-800.woff2
92+
theme/fonts/open-sans-v17-all-charsets-800italic.woff2
93+
theme/fonts/open-sans-v17-all-charsets-italic.woff2
94+
theme/fonts/open-sans-v17-all-charsets-regular.woff2
95+
theme/fonts/source-code-pro-v11-all-charsets-500.woff2
96+
"#]],
97+
)
98+
.check_file_list(
99+
"book/fonts",
100+
str![[r#"
101+
book/fonts/OPEN-SANS-LICENSE.txt
102+
book/fonts/SOURCE-CODE-PRO-LICENSE.txt
103+
book/fonts/fonts.css
104+
book/fonts/open-sans-v17-all-charsets-300.woff2
105+
book/fonts/open-sans-v17-all-charsets-300italic.woff2
106+
book/fonts/open-sans-v17-all-charsets-600.woff2
107+
book/fonts/open-sans-v17-all-charsets-600italic.woff2
108+
book/fonts/open-sans-v17-all-charsets-700.woff2
109+
book/fonts/open-sans-v17-all-charsets-700italic.woff2
110+
book/fonts/open-sans-v17-all-charsets-800.woff2
111+
book/fonts/open-sans-v17-all-charsets-800italic.woff2
112+
book/fonts/open-sans-v17-all-charsets-italic.woff2
113+
book/fonts/open-sans-v17-all-charsets-regular.woff2
114+
book/fonts/source-code-pro-v11-all-charsets-500.woff2
115+
"#]],
116+
);
117+
}

0 commit comments

Comments
 (0)