Skip to content

Commit d65d2b2

Browse files
committed
Migrate summary_with_markdown_formatting to BookTest
1 parent 6997208 commit d65d2b2

File tree

3 files changed

+49
-36
lines changed

3 files changed

+49
-36
lines changed

tests/rendered_output.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -106,39 +106,3 @@ fn example_book_can_build() {
106106

107107
md.build().unwrap();
108108
}
109-
110-
/// Checks formatting of summary names with inline elements.
111-
#[test]
112-
fn summary_with_markdown_formatting() {
113-
let temp = DummyBook::new().build().unwrap();
114-
let mut cfg = Config::default();
115-
cfg.set("book.src", "summary-formatting").unwrap();
116-
let md = MDBook::load_with_config(temp.path(), cfg).unwrap();
117-
md.build().unwrap();
118-
119-
let rendered_path = temp.path().join("book/toc.js");
120-
assert_contains_strings(
121-
rendered_path,
122-
&[
123-
r#"<a href="formatted-summary.html"><strong aria-hidden="true">1.</strong> Italic code *escape* `escape2`</a>"#,
124-
r#"<a href="soft.html"><strong aria-hidden="true">2.</strong> Soft line break</a>"#,
125-
r#"<a href="escaped-tag.html"><strong aria-hidden="true">3.</strong> &lt;escaped tag&gt;</a>"#,
126-
],
127-
);
128-
129-
let generated_md = temp.path().join("summary-formatting/formatted-summary.md");
130-
assert_eq!(
131-
fs::read_to_string(generated_md).unwrap(),
132-
"# Italic code *escape* `escape2`\n"
133-
);
134-
let generated_md = temp.path().join("summary-formatting/soft.md");
135-
assert_eq!(
136-
fs::read_to_string(generated_md).unwrap(),
137-
"# Soft line break\n"
138-
);
139-
let generated_md = temp.path().join("summary-formatting/escaped-tag.md");
140-
assert_eq!(
141-
fs::read_to_string(generated_md).unwrap(),
142-
"# &lt;escaped tag&gt;\n"
143-
);
144-
}

tests/testsuite/toc.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,46 @@ fn check_link_target_fallback() {
142142
TOC_TOP_LEVEL.len() + TOC_SECOND_LEVEL.len()
143143
);
144144
}
145+
146+
// Checks formatting of summary names with inline elements.
147+
#[test]
148+
fn summary_with_markdown_formatting() {
149+
BookTest::from_dir("toc/summary_with_markdown_formatting")
150+
.check_toc_js(str![[r#"
151+
<ol class="chapter">
152+
<li class="chapter-item expanded ">
153+
<a href="formatted-summary.html">
154+
<strong aria-hidden="true">1.</strong> Italic code *escape* `escape2`</a>
155+
</li>
156+
<li class="chapter-item expanded ">
157+
<a href="soft.html">
158+
<strong aria-hidden="true">2.</strong> Soft line break</a>
159+
</li>
160+
<li class="chapter-item expanded ">
161+
<a href="escaped-tag.html">
162+
<strong aria-hidden="true">3.</strong> &lt;escaped tag&gt;</a>
163+
</li>
164+
</ol>
165+
"#]])
166+
.check_file(
167+
"src/formatted-summary.md",
168+
str![[r#"
169+
# Italic code *escape* `escape2`
170+
171+
"#]],
172+
)
173+
.check_file(
174+
"src/soft.md",
175+
str![[r#"
176+
# Soft line break
177+
178+
"#]],
179+
)
180+
.check_file(
181+
"src/escaped-tag.md",
182+
str![[r#"
183+
# &lt;escaped tag&gt;
184+
185+
"#]],
186+
);
187+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Summary formatting tests
2+
3+
- [*Italic* `code` \*escape\* \`escape2\`](formatted-summary.md)
4+
- [Soft
5+
line break](soft.md)
6+
- [\<escaped tag\>](escaped-tag.md)

0 commit comments

Comments
 (0)