Skip to content

Commit c2c3770

Browse files
committed
Migrate custom fonts.css to BookTest
1 parent 5f22761 commit c2c3770

File tree

5 files changed

+24
-14
lines changed

5 files changed

+24
-14
lines changed

tests/rendered_output.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -323,20 +323,6 @@ fn custom_fonts() {
323323
contents.contains("fonts/fonts.css")
324324
};
325325

326-
// Mixed with copy-fonts=true
327-
// Should ignore the copy-fonts setting since the user has provided their own fonts.css.
328-
let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap();
329-
let p = temp.path();
330-
MDBook::init(p).build().unwrap();
331-
write_file(&p.join("theme/fonts"), "fonts.css", b"/*custom*/").unwrap();
332-
write_file(&p.join("theme/fonts"), "myfont.woff", b"").unwrap();
333-
MDBook::load(p).unwrap().build().unwrap();
334-
assert!(has_fonts_css(p));
335-
assert_eq!(
336-
actual_files(&p.join("book/fonts")),
337-
["fonts.css", "myfont.woff"]
338-
);
339-
340326
// copy-fonts=false, no theme
341327
// This should generate a deprecation warning.
342328
let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap();

tests/testsuite/theme.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,25 @@ book/fonts/source-code-pro-v11-all-charsets-500.woff2
115115
"#]],
116116
);
117117
}
118+
119+
// Custom fonts.css.
120+
#[test]
121+
fn fonts_css() {
122+
BookTest::from_dir("theme/fonts_css")
123+
.check_file_contains("book/index.html", "fonts/fonts.css")
124+
.check_file(
125+
"book/fonts/fonts.css",
126+
str![[r#"
127+
/*custom*/
128+
129+
"#]],
130+
)
131+
.check_file("book/fonts/myfont.woff", str![[""]])
132+
.check_file_list(
133+
"book/fonts",
134+
str![[r#"
135+
book/fonts/fonts.css
136+
book/fonts/myfont.woff
137+
"#]],
138+
);
139+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- [With Fonts](index.md)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/*custom*/

tests/testsuite/theme/fonts_css/theme/fonts/myfont.woff

Whitespace-only changes.

0 commit comments

Comments
 (0)