Migrate copy theme default fonts to BookTest
This commit is contained in:
parent
0274ad6e87
commit
5f227613aa
2 changed files with 47 additions and 25 deletions
|
|
@ -309,22 +309,6 @@ fn summary_with_markdown_formatting() {
|
|||
#[test]
|
||||
fn custom_fonts() {
|
||||
// Tests to ensure custom fonts are copied as expected.
|
||||
let builtin_fonts = [
|
||||
"OPEN-SANS-LICENSE.txt",
|
||||
"SOURCE-CODE-PRO-LICENSE.txt",
|
||||
"fonts.css",
|
||||
"open-sans-v17-all-charsets-300.woff2",
|
||||
"open-sans-v17-all-charsets-300italic.woff2",
|
||||
"open-sans-v17-all-charsets-600.woff2",
|
||||
"open-sans-v17-all-charsets-600italic.woff2",
|
||||
"open-sans-v17-all-charsets-700.woff2",
|
||||
"open-sans-v17-all-charsets-700italic.woff2",
|
||||
"open-sans-v17-all-charsets-800.woff2",
|
||||
"open-sans-v17-all-charsets-800italic.woff2",
|
||||
"open-sans-v17-all-charsets-italic.woff2",
|
||||
"open-sans-v17-all-charsets-regular.woff2",
|
||||
"source-code-pro-v11-all-charsets-500.woff2",
|
||||
];
|
||||
let actual_files = |path: &Path| -> Vec<String> {
|
||||
let mut actual: Vec<_> = path
|
||||
.read_dir()
|
||||
|
|
@ -339,15 +323,6 @@ fn custom_fonts() {
|
|||
contents.contains("fonts/fonts.css")
|
||||
};
|
||||
|
||||
// Full theme.
|
||||
let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap();
|
||||
let p = temp.path();
|
||||
MDBook::init(p).copy_theme(true).build().unwrap();
|
||||
assert_eq!(actual_files(&p.join("theme/fonts")), &builtin_fonts);
|
||||
MDBook::load(p).unwrap().build().unwrap();
|
||||
assert_eq!(actual_files(&p.join("book/fonts")), &builtin_fonts);
|
||||
assert!(has_fonts_css(p));
|
||||
|
||||
// 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();
|
||||
|
|
|
|||
|
|
@ -68,3 +68,50 @@ book/fonts/source-code-pro-v11-all-charsets-500.woff2
|
|||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
// When the theme is initialized, what does the fonts list look like?
|
||||
#[test]
|
||||
fn theme_fonts_copied() {
|
||||
BookTest::init(|bb| {
|
||||
bb.copy_theme(true);
|
||||
})
|
||||
.check_file_contains("book/index.html", "fonts/fonts.css")
|
||||
.check_file_list(
|
||||
"theme/fonts",
|
||||
str![[r#"
|
||||
theme/fonts/OPEN-SANS-LICENSE.txt
|
||||
theme/fonts/SOURCE-CODE-PRO-LICENSE.txt
|
||||
theme/fonts/fonts.css
|
||||
theme/fonts/open-sans-v17-all-charsets-300.woff2
|
||||
theme/fonts/open-sans-v17-all-charsets-300italic.woff2
|
||||
theme/fonts/open-sans-v17-all-charsets-600.woff2
|
||||
theme/fonts/open-sans-v17-all-charsets-600italic.woff2
|
||||
theme/fonts/open-sans-v17-all-charsets-700.woff2
|
||||
theme/fonts/open-sans-v17-all-charsets-700italic.woff2
|
||||
theme/fonts/open-sans-v17-all-charsets-800.woff2
|
||||
theme/fonts/open-sans-v17-all-charsets-800italic.woff2
|
||||
theme/fonts/open-sans-v17-all-charsets-italic.woff2
|
||||
theme/fonts/open-sans-v17-all-charsets-regular.woff2
|
||||
theme/fonts/source-code-pro-v11-all-charsets-500.woff2
|
||||
"#]],
|
||||
)
|
||||
.check_file_list(
|
||||
"book/fonts",
|
||||
str![[r#"
|
||||
book/fonts/OPEN-SANS-LICENSE.txt
|
||||
book/fonts/SOURCE-CODE-PRO-LICENSE.txt
|
||||
book/fonts/fonts.css
|
||||
book/fonts/open-sans-v17-all-charsets-300.woff2
|
||||
book/fonts/open-sans-v17-all-charsets-300italic.woff2
|
||||
book/fonts/open-sans-v17-all-charsets-600.woff2
|
||||
book/fonts/open-sans-v17-all-charsets-600italic.woff2
|
||||
book/fonts/open-sans-v17-all-charsets-700.woff2
|
||||
book/fonts/open-sans-v17-all-charsets-700italic.woff2
|
||||
book/fonts/open-sans-v17-all-charsets-800.woff2
|
||||
book/fonts/open-sans-v17-all-charsets-800italic.woff2
|
||||
book/fonts/open-sans-v17-all-charsets-italic.woff2
|
||||
book/fonts/open-sans-v17-all-charsets-regular.woff2
|
||||
book/fonts/source-code-pro-v11-all-charsets-500.woff2
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue