Migrate anchors_include_text_between_but_not_anchor_comments to BookTest

This commit is contained in:
Eric Huss 2025-04-21 18:44:53 -07:00
parent 03470a7531
commit 7add0dbf10
2 changed files with 15 additions and 14 deletions

View file

@ -127,20 +127,6 @@ fn rendered_code_does_not_have_playground_stuff_in_html_when_disabled_in_config(
assert_doesnt_contain_strings(nested, &playground_class);
}
#[test]
fn anchors_include_text_between_but_not_anchor_comments() {
let temp = DummyBook::new().build().unwrap();
let md = MDBook::load(temp.path()).unwrap();
md.build().unwrap();
let nested = temp.path().join("book/first/nested.html");
let text_between_anchors = vec!["unique-string-for-anchor-test"];
let anchor_text = vec!["ANCHOR"];
assert_contains_strings(nested.clone(), &text_between_anchors);
assert_doesnt_contain_strings(nested, &anchor_text);
}
#[test]
fn rustdoc_include_hides_the_unspecified_part_of_the_file() {
let temp = DummyBook::new().build().unwrap();

View file

@ -23,3 +23,18 @@ fn include() {
"##]],
);
}
// Checks for anchored includes.
#[test]
fn anchored_include() {
BookTest::from_dir("includes/all_includes").check_main_file(
"book/anchors.html",
str![[r##"
<h1 id="include-anchors"><a class="header" href="#include-anchors">Include Anchors</a></h1>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span>let x = 1;
<span class="boring">}</span></code></pre></pre>
"##]],
);
}