Migrate theme_dir_overrides_work_correctly to BookTest

This commit is contained in:
Eric Huss 2025-04-22 11:08:23 -07:00
parent 25b9acc321
commit dd27c4f8ba
4 changed files with 14 additions and 18 deletions

View file

@ -270,24 +270,6 @@ fn example_book_can_build() {
md.build().unwrap();
}
#[test]
fn theme_dir_overrides_work_correctly() {
let book_dir = dummy_book::new_copy_of_example_book().unwrap();
let book_dir = book_dir.path();
let theme_dir = book_dir.join("theme");
let mut index = mdbook::theme::INDEX.to_vec();
index.extend_from_slice(b"\n<!-- This is a modified index.hbs! -->");
write_file(&theme_dir, "index.hbs", &index).unwrap();
let md = MDBook::load(book_dir).unwrap();
md.build().unwrap();
let built_index = book_dir.join("book").join("index.html");
dummy_book::assert_contains_strings(built_index, &["This is a modified index.hbs!"]);
}
/// Checks formatting of summary names with inline elements.
#[test]
fn summary_with_markdown_formatting() {

View file

@ -30,3 +30,15 @@ fn empty_theme() {
"#]]);
});
}
// Checks overriding index.hbs.
#[test]
fn override_index() {
BookTest::from_dir("theme/override_index").check_file(
"book/index.html",
str![[r#"
This is a modified index.hbs!
"#]],
);
}

View file

@ -0,0 +1 @@
- [Intro](index.md)

View file

@ -0,0 +1 @@
This is a modified index.hbs!