diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index 88d44fef..47b5fc9f 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -72,27 +72,6 @@ fn check_correct_cross_links_in_nested_dir() { ); } -#[test] -fn check_correct_relative_links_in_print_page() { - let temp = DummyBook::new().build().unwrap(); - let md = MDBook::load(temp.path()).unwrap(); - md.build().unwrap(); - - let first = temp.path().join("book"); - - assert_contains_strings( - first.join("print.html"), - &[ - r##"the first section,"##, - r##"outside"##, - r##"Some image"##, - r##"fragment link"##, - r##"HTML Link"##, - r##"raw html"##, - ], - ); -} - #[test] fn chapter_content_appears_in_rendered_document() { let content = vec![ diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs index daec2814..298cf12d 100644 --- a/tests/testsuite/main.rs +++ b/tests/testsuite/main.rs @@ -11,6 +11,7 @@ mod init; mod markdown; mod playground; mod preprocessor; +mod print; mod prelude { pub use crate::book_test::BookTest; diff --git a/tests/testsuite/print.rs b/tests/testsuite/print.rs new file mode 100644 index 00000000..bac27a06 --- /dev/null +++ b/tests/testsuite/print.rs @@ -0,0 +1,23 @@ +//! Tests for print page. + +use crate::prelude::*; + +// Tests relative links from the print page. +#[test] +fn relative_links() { + BookTest::from_dir("print/relative_links") + .check_main_file("book/print.html", + str![[r##" +

First Chapter

+

First Nested

+

Testing relative links for the print page

+

When we link to the first section, it should work on +both the print page and the non-print page.

+

A fragment link should work.

+

Link outside.

+

Some image

+

HTML Link

+raw html +

Some section

+"##]]); +} diff --git a/tests/testsuite/print/relative_links/book.toml b/tests/testsuite/print/relative_links/book.toml new file mode 100644 index 00000000..80822350 --- /dev/null +++ b/tests/testsuite/print/relative_links/book.toml @@ -0,0 +1,2 @@ +[book] +title = "relative_links" diff --git a/tests/testsuite/print/relative_links/src/SUMMARY.md b/tests/testsuite/print/relative_links/src/SUMMARY.md new file mode 100644 index 00000000..229e7aac --- /dev/null +++ b/tests/testsuite/print/relative_links/src/SUMMARY.md @@ -0,0 +1,5 @@ +# Summary + +- [First Chapter](first/index.md) + - [First Nested](first/nested.md) +- [Second Chapter](second/nested.md) diff --git a/tests/testsuite/print/relative_links/src/first/index.md b/tests/testsuite/print/relative_links/src/first/index.md new file mode 100644 index 00000000..4f8bda17 --- /dev/null +++ b/tests/testsuite/print/relative_links/src/first/index.md @@ -0,0 +1 @@ +# First Chapter diff --git a/tests/testsuite/print/relative_links/src/first/nested.md b/tests/testsuite/print/relative_links/src/first/nested.md new file mode 100644 index 00000000..e207dd37 --- /dev/null +++ b/tests/testsuite/print/relative_links/src/first/nested.md @@ -0,0 +1 @@ +# First Nested diff --git a/tests/testsuite/print/relative_links/src/second/nested.md b/tests/testsuite/print/relative_links/src/second/nested.md new file mode 100644 index 00000000..faf1187f --- /dev/null +++ b/tests/testsuite/print/relative_links/src/second/nested.md @@ -0,0 +1,16 @@ +# Testing relative links for the print page + +When we link to [the first section](../first/nested.md), it should work on +both the print page and the non-print page. + +A [fragment link](#some-section) should work. + +Link [outside](../../std/foo/bar.html). + +![Some image](../images/picture.png) + +HTML Link + +raw html + +## Some section