diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index c2e7c600..7cb1888d 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -106,39 +106,3 @@ fn example_book_can_build() { md.build().unwrap(); } - -/// Checks formatting of summary names with inline elements. -#[test] -fn summary_with_markdown_formatting() { - let temp = DummyBook::new().build().unwrap(); - let mut cfg = Config::default(); - cfg.set("book.src", "summary-formatting").unwrap(); - let md = MDBook::load_with_config(temp.path(), cfg).unwrap(); - md.build().unwrap(); - - let rendered_path = temp.path().join("book/toc.js"); - assert_contains_strings( - rendered_path, - &[ - r#" Italic code *escape* `escape2`"#, - r#" Soft line break"#, - r#" <escaped tag>"#, - ], - ); - - let generated_md = temp.path().join("summary-formatting/formatted-summary.md"); - assert_eq!( - fs::read_to_string(generated_md).unwrap(), - "# Italic code *escape* `escape2`\n" - ); - let generated_md = temp.path().join("summary-formatting/soft.md"); - assert_eq!( - fs::read_to_string(generated_md).unwrap(), - "# Soft line break\n" - ); - let generated_md = temp.path().join("summary-formatting/escaped-tag.md"); - assert_eq!( - fs::read_to_string(generated_md).unwrap(), - "# <escaped tag>\n" - ); -} diff --git a/tests/testsuite/toc.rs b/tests/testsuite/toc.rs index 77021f66..eafbdc48 100644 --- a/tests/testsuite/toc.rs +++ b/tests/testsuite/toc.rs @@ -142,3 +142,46 @@ fn check_link_target_fallback() { TOC_TOP_LEVEL.len() + TOC_SECOND_LEVEL.len() ); } + +// Checks formatting of summary names with inline elements. +#[test] +fn summary_with_markdown_formatting() { + BookTest::from_dir("toc/summary_with_markdown_formatting") + .check_toc_js(str![[r#" +
    +
  1. + + Italic code *escape* `escape2` +
  2. +
  3. + + Soft line break +
  4. +
  5. + + <escaped tag> +
  6. +
+"#]]) + .check_file( + "src/formatted-summary.md", + str![[r#" +# Italic code *escape* `escape2` + +"#]], + ) + .check_file( + "src/soft.md", + str![[r#" +# Soft line break + +"#]], + ) + .check_file( + "src/escaped-tag.md", + str![[r#" +# <escaped tag> + +"#]], + ); +} diff --git a/tests/testsuite/toc/summary_with_markdown_formatting/src/SUMMARY.md b/tests/testsuite/toc/summary_with_markdown_formatting/src/SUMMARY.md new file mode 100644 index 00000000..336218d8 --- /dev/null +++ b/tests/testsuite/toc/summary_with_markdown_formatting/src/SUMMARY.md @@ -0,0 +1,6 @@ +# Summary formatting tests + +- [*Italic* `code` \*escape\* \`escape2\`](formatted-summary.md) +- [Soft +line break](soft.md) +- [\](escaped-tag.md)