From 50dfa365c7d95aea4e91cbe5396a5e82a52bbb9d Mon Sep 17 00:00:00 2001
From: Eric Huss
Date: Mon, 21 Apr 2025 19:24:13 -0700
Subject: [PATCH] Migrate no_index_for_print_html to BookTest
---
tests/rendered_output.rs | 13 -------------
tests/testsuite/print.rs | 9 +++++++++
tests/testsuite/print/noindex/src/SUMMARY.md | 1 +
3 files changed, 10 insertions(+), 13 deletions(-)
create mode 100644 tests/testsuite/print/noindex/src/SUMMARY.md
diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs
index 47b5fc9f..e66791f6 100644
--- a/tests/rendered_output.rs
+++ b/tests/rendered_output.rs
@@ -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();
diff --git a/tests/testsuite/print.rs b/tests/testsuite/print.rs
index bac27a06..0e0cdfe0 100644
--- a/tests/testsuite/print.rs
+++ b/tests/testsuite/print.rs
@@ -21,3 +21,12 @@ both the print page and the non-print page.
"##]]);
}
+
+// Checks that print.html is noindex.
+#[test]
+fn noindex() {
+ let robots = r#""#;
+ BookTest::from_dir("print/noindex")
+ .check_file_contains("book/print.html", robots)
+ .check_file_doesnt_contain("book/index.html", robots);
+}
diff --git a/tests/testsuite/print/noindex/src/SUMMARY.md b/tests/testsuite/print/noindex/src/SUMMARY.md
new file mode 100644
index 00000000..655a0ded
--- /dev/null
+++ b/tests/testsuite/print/noindex/src/SUMMARY.md
@@ -0,0 +1 @@
+- [Intro](index.md)