Migrate custom fonts.css to BookTest
This commit is contained in:
parent
5f227613aa
commit
c2c37705e7
5 changed files with 24 additions and 14 deletions
|
|
@ -323,20 +323,6 @@ fn custom_fonts() {
|
||||||
contents.contains("fonts/fonts.css")
|
contents.contains("fonts/fonts.css")
|
||||||
};
|
};
|
||||||
|
|
||||||
// Mixed with copy-fonts=true
|
|
||||||
// Should ignore the copy-fonts setting since the user has provided their own fonts.css.
|
|
||||||
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();
|
|
||||||
MDBook::load(p).unwrap().build().unwrap();
|
|
||||||
assert!(has_fonts_css(p));
|
|
||||||
assert_eq!(
|
|
||||||
actual_files(&p.join("book/fonts")),
|
|
||||||
["fonts.css", "myfont.woff"]
|
|
||||||
);
|
|
||||||
|
|
||||||
// copy-fonts=false, no theme
|
// copy-fonts=false, no theme
|
||||||
// This should generate a deprecation warning.
|
// This should generate a deprecation warning.
|
||||||
let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap();
|
let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap();
|
||||||
|
|
|
||||||
|
|
@ -115,3 +115,25 @@ book/fonts/source-code-pro-v11-all-charsets-500.woff2
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Custom fonts.css.
|
||||||
|
#[test]
|
||||||
|
fn fonts_css() {
|
||||||
|
BookTest::from_dir("theme/fonts_css")
|
||||||
|
.check_file_contains("book/index.html", "fonts/fonts.css")
|
||||||
|
.check_file(
|
||||||
|
"book/fonts/fonts.css",
|
||||||
|
str![[r#"
|
||||||
|
/*custom*/
|
||||||
|
|
||||||
|
"#]],
|
||||||
|
)
|
||||||
|
.check_file("book/fonts/myfont.woff", str![[""]])
|
||||||
|
.check_file_list(
|
||||||
|
"book/fonts",
|
||||||
|
str![[r#"
|
||||||
|
book/fonts/fonts.css
|
||||||
|
book/fonts/myfont.woff
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
||||||
1
tests/testsuite/theme/fonts_css/src/SUMMARY.md
Normal file
1
tests/testsuite/theme/fonts_css/src/SUMMARY.md
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
- [With Fonts](index.md)
|
||||||
1
tests/testsuite/theme/fonts_css/theme/fonts/fonts.css
Normal file
1
tests/testsuite/theme/fonts_css/theme/fonts/fonts.css
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
/*custom*/
|
||||||
0
tests/testsuite/theme/fonts_css/theme/fonts/myfont.woff
Normal file
0
tests/testsuite/theme/fonts_css/theme/fonts/myfont.woff
Normal file
Loading…
Add table
Reference in a new issue