Migrate copy_theme to BookTest
This commit is contained in:
parent
29338b5ade
commit
0732cb47b9
2 changed files with 44 additions and 51 deletions
|
|
@ -1,51 +0,0 @@
|
|||
use mdbook::MDBook;
|
||||
use pretty_assertions::assert_eq;
|
||||
use tempfile::Builder as TempFileBuilder;
|
||||
|
||||
#[test]
|
||||
fn copy_theme() {
|
||||
let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap();
|
||||
MDBook::init(temp.path()).copy_theme(true).build().unwrap();
|
||||
let expected = vec![
|
||||
"book.js",
|
||||
"css/chrome.css",
|
||||
"css/general.css",
|
||||
"css/print.css",
|
||||
"css/variables.css",
|
||||
"favicon.png",
|
||||
"favicon.svg",
|
||||
"fonts/OPEN-SANS-LICENSE.txt",
|
||||
"fonts/SOURCE-CODE-PRO-LICENSE.txt",
|
||||
"fonts/fonts.css",
|
||||
"fonts/open-sans-v17-all-charsets-300.woff2",
|
||||
"fonts/open-sans-v17-all-charsets-300italic.woff2",
|
||||
"fonts/open-sans-v17-all-charsets-600.woff2",
|
||||
"fonts/open-sans-v17-all-charsets-600italic.woff2",
|
||||
"fonts/open-sans-v17-all-charsets-700.woff2",
|
||||
"fonts/open-sans-v17-all-charsets-700italic.woff2",
|
||||
"fonts/open-sans-v17-all-charsets-800.woff2",
|
||||
"fonts/open-sans-v17-all-charsets-800italic.woff2",
|
||||
"fonts/open-sans-v17-all-charsets-italic.woff2",
|
||||
"fonts/open-sans-v17-all-charsets-regular.woff2",
|
||||
"fonts/source-code-pro-v11-all-charsets-500.woff2",
|
||||
"highlight.css",
|
||||
"highlight.js",
|
||||
"index.hbs",
|
||||
];
|
||||
let theme_dir = temp.path().join("theme");
|
||||
let mut actual: Vec<_> = walkdir::WalkDir::new(&theme_dir)
|
||||
.into_iter()
|
||||
.filter_map(|e| e.ok())
|
||||
.filter(|e| !e.file_type().is_dir())
|
||||
.map(|e| {
|
||||
e.path()
|
||||
.strip_prefix(&theme_dir)
|
||||
.unwrap()
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.replace('\\', "/")
|
||||
})
|
||||
.collect();
|
||||
actual.sort();
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
|
@ -207,3 +207,47 @@ use-default-preprocessors = true
|
|||
);
|
||||
assert!(test.dir.join("out").exists());
|
||||
}
|
||||
|
||||
// Copies the theme into the initialized directory.
|
||||
#[test]
|
||||
fn copy_theme() {
|
||||
BookTest::empty()
|
||||
.run("init --theme", |_| {})
|
||||
.check_file_list(
|
||||
".",
|
||||
str![[r#"
|
||||
book
|
||||
book.toml
|
||||
src
|
||||
src/SUMMARY.md
|
||||
src/chapter_1.md
|
||||
theme
|
||||
theme/book.js
|
||||
theme/css
|
||||
theme/css/chrome.css
|
||||
theme/css/general.css
|
||||
theme/css/print.css
|
||||
theme/css/variables.css
|
||||
theme/favicon.png
|
||||
theme/favicon.svg
|
||||
theme/fonts
|
||||
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
|
||||
theme/highlight.css
|
||||
theme/highlight.js
|
||||
theme/index.hbs
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue