diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index c935fae0..d16c7a3f 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -271,21 +271,6 @@ fn example_book_can_build() { md.build().unwrap(); } -#[test] -fn first_chapter_is_copied_as_index_even_if_not_first_elem() { - let temp = DummyBook::new().build().unwrap(); - let mut cfg = Config::default(); - cfg.set("book.src", "index_html_test") - .expect("Couldn't set config.book.src to \"index_html_test\""); - let md = MDBook::load_with_config(temp.path(), cfg).unwrap(); - md.build().unwrap(); - - let root = temp.path().join("book"); - let chapter = fs::read_to_string(root.join("chapter_1.html")).expect("read chapter 1"); - let index = fs::read_to_string(root.join("index.html")).expect("read index"); - pretty_assertions::assert_eq!(chapter, index); -} - #[test] fn theme_dir_overrides_work_correctly() { let book_dir = dummy_book::new_copy_of_example_book().unwrap(); diff --git a/tests/testsuite/rendering.rs b/tests/testsuite/rendering.rs index 750e27dd..1d6cf476 100644 --- a/tests/testsuite/rendering.rs +++ b/tests/testsuite/rendering.rs @@ -21,3 +21,23 @@ fn edit_url_template_explicit_src() { title=\"Suggest an edit\" aria-label=\"Suggest an edit\">", ); } + +// Checks that index.html is generated correctly, even when the first few +// chapters are drafts. +#[test] +fn first_chapter_is_copied_as_index_even_if_not_first_elem() { + BookTest::from_dir("rendering/first_chapter_is_copied_as_index_even_if_not_first_elem") + // These two files should be equal. + .check_main_file( + "book/chapter_1.html", + str![[ + r##"