mirror of
https://github.com/rust-lang/mdBook.git
synced 2025-12-27 09:05:40 -05:00
This adds a bunch of tests to better exercise the HTML rendering and to be able to track any changes in its behavior. This includes a new `check_all_main_files` to more conveniently check the HTML content of every chapter in a book.
41 lines
1.1 KiB
Rust
41 lines
1.1 KiB
Rust
//! Tests for print page.
|
|
|
|
use crate::prelude::*;
|
|
use snapbox::file;
|
|
|
|
// Tests relative links from the print page.
|
|
#[test]
|
|
fn relative_links() {
|
|
BookTest::from_dir("print/relative_links").check_main_file(
|
|
"book/print.html",
|
|
file!("print/relative_links/expected/print.html"),
|
|
);
|
|
}
|
|
|
|
// Test for duplicate IDs, and links to those duplicates.
|
|
#[test]
|
|
fn duplicate_ids() {
|
|
BookTest::from_dir("print/duplicate_ids").check_main_file(
|
|
"book/print.html",
|
|
file!("print/duplicate_ids/expected/print.html"),
|
|
);
|
|
}
|
|
|
|
// Test for synthesized link to a chapter that does not have an h1.
|
|
#[test]
|
|
fn chapter_no_h1() {
|
|
BookTest::from_dir("print/chapter_no_h1").check_main_file(
|
|
"book/print.html",
|
|
file!("print/chapter_no_h1/expected/print.html"),
|
|
);
|
|
}
|
|
|
|
// 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);
|
|
}
|