Migrate custom fonts with filled fonts.css to BookTest
This commit is contained in:
parent
bdd16e25fa
commit
707319e004
6 changed files with 25 additions and 35 deletions
|
|
@ -305,38 +305,3 @@ fn summary_with_markdown_formatting() {
|
|||
"# <escaped tag>\n"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn custom_fonts() {
|
||||
// Tests to ensure custom fonts are copied as expected.
|
||||
let actual_files = |path: &Path| -> Vec<String> {
|
||||
let mut actual: Vec<_> = path
|
||||
.read_dir()
|
||||
.unwrap()
|
||||
.map(|entry| entry.unwrap().file_name().into_string().unwrap())
|
||||
.collect();
|
||||
actual.sort();
|
||||
actual
|
||||
};
|
||||
let has_fonts_css = |path: &Path| -> bool {
|
||||
let contents = fs::read_to_string(path.join("book/index.html")).unwrap();
|
||||
contents.contains("fonts/fonts.css")
|
||||
};
|
||||
|
||||
// copy-fonts=false with fonts theme
|
||||
let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap();
|
||||
let p = temp.path();
|
||||
MDBook::init(p).build().unwrap();
|
||||
write_file(&p.join("theme/fonts"), "fonts.css", b"/*custom*/").unwrap();
|
||||
write_file(&p.join("theme/fonts"), "myfont.woff", b"").unwrap();
|
||||
let config = Config::from_str("output.html.copy-fonts = false").unwrap();
|
||||
MDBook::load_with_config(p, config)
|
||||
.unwrap()
|
||||
.build()
|
||||
.unwrap();
|
||||
assert!(has_fonts_css(p));
|
||||
assert_eq!(
|
||||
actual_files(&p.join("book/fonts")),
|
||||
&["fonts.css", "myfont.woff"]
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,3 +170,24 @@ fn copy_fonts_false_with_empty_fonts_css() {
|
|||
.check_file_doesnt_contain("book/index.html", "fonts.css")
|
||||
.check_file_list("book/fonts", str![[""]]);
|
||||
}
|
||||
|
||||
// copy-fonts=false, fonts.css has contents
|
||||
#[test]
|
||||
fn copy_fonts_false_with_fonts_css() {
|
||||
BookTest::from_dir("theme/copy_fonts_false_with_fonts_css")
|
||||
.run("build", |cmd| {
|
||||
cmd.expect_stderr(str![[r#"
|
||||
[TIMESTAMP] [INFO] (mdbook::book): Book building has started
|
||||
[TIMESTAMP] [INFO] (mdbook::book): Running the html backend
|
||||
|
||||
"#]]);
|
||||
})
|
||||
.check_file_contains("book/index.html", "fonts.css")
|
||||
.check_file_list(
|
||||
"book/fonts",
|
||||
str![[r#"
|
||||
book/fonts/fonts.css
|
||||
book/fonts/myfont.woff
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
[output.html]
|
||||
copy-fonts = false
|
||||
|
|
@ -0,0 +1 @@
|
|||
- [Intro](index.md)
|
||||
|
|
@ -0,0 +1 @@
|
|||
/*custom*/
|
||||
Loading…
Add table
Reference in a new issue