Migrate no_index_for_print_html to BookTest

This commit is contained in:
Eric Huss 2025-04-21 19:24:13 -07:00
parent 3e22a5cdad
commit 50dfa365c7
3 changed files with 10 additions and 13 deletions

View file

@ -306,19 +306,6 @@ fn theme_dir_overrides_work_correctly() {
dummy_book::assert_contains_strings(built_index, &["This is a modified index.hbs!"]);
}
#[test]
fn no_index_for_print_html() {
let temp = DummyBook::new().build().unwrap();
let md = MDBook::load(temp.path()).unwrap();
md.build().unwrap();
let print_html = temp.path().join("book/print.html");
assert_contains_strings(print_html, &[r##"noindex"##]);
let index_html = temp.path().join("book/index.html");
assert_doesnt_contain_strings(index_html, &[r##"noindex"##]);
}
#[test]
fn redirects_are_emitted_correctly() {
let temp = DummyBook::new().build().unwrap();

View file

@ -21,3 +21,12 @@ both the print page and the non-print page.</p>
<h2 id="some-section"><a class="header" href="#some-section">Some section</a></h2>
"##]]);
}
// Checks that print.html is noindex.
#[test]
fn noindex() {
let robots = r#"<meta name="robots" content="noindex">"#;
BookTest::from_dir("print/noindex")
.check_file_contains("book/print.html", robots)
.check_file_doesnt_contain("book/index.html", robots);
}

View file

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