Migrate summary_with_markdown_formatting to BookTest
This commit is contained in:
parent
69972080f0
commit
d65d2b2a8e
3 changed files with 49 additions and 36 deletions
|
|
@ -106,39 +106,3 @@ fn example_book_can_build() {
|
||||||
|
|
||||||
md.build().unwrap();
|
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#"<a href="formatted-summary.html"><strong aria-hidden="true">1.</strong> Italic code *escape* `escape2`</a>"#,
|
|
||||||
r#"<a href="soft.html"><strong aria-hidden="true">2.</strong> Soft line break</a>"#,
|
|
||||||
r#"<a href="escaped-tag.html"><strong aria-hidden="true">3.</strong> <escaped tag></a>"#,
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
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"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -142,3 +142,46 @@ fn check_link_target_fallback() {
|
||||||
TOC_TOP_LEVEL.len() + TOC_SECOND_LEVEL.len()
|
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#"
|
||||||
|
<ol class="chapter">
|
||||||
|
<li class="chapter-item expanded ">
|
||||||
|
<a href="formatted-summary.html">
|
||||||
|
<strong aria-hidden="true">1.</strong> Italic code *escape* `escape2`</a>
|
||||||
|
</li>
|
||||||
|
<li class="chapter-item expanded ">
|
||||||
|
<a href="soft.html">
|
||||||
|
<strong aria-hidden="true">2.</strong> Soft line break</a>
|
||||||
|
</li>
|
||||||
|
<li class="chapter-item expanded ">
|
||||||
|
<a href="escaped-tag.html">
|
||||||
|
<strong aria-hidden="true">3.</strong> <escaped tag></a>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
"#]])
|
||||||
|
.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>
|
||||||
|
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
# Summary formatting tests
|
||||||
|
|
||||||
|
- [*Italic* `code` \*escape\* \`escape2\`](formatted-summary.md)
|
||||||
|
- [Soft
|
||||||
|
line break](soft.md)
|
||||||
|
- [\<escaped tag\>](escaped-tag.md)
|
||||||
Loading…
Add table
Reference in a new issue