Migrate rendered_code_does_not_have_playground_stuff_in_html_when_disabled_in_config to BookTest

This commit is contained in:
Eric Huss 2025-04-21 19:11:53 -07:00
parent 20d42a53d3
commit aa29ef04a2
5 changed files with 25 additions and 19 deletions

View file

@ -93,25 +93,6 @@ fn check_correct_relative_links_in_print_page() {
);
}
#[test]
fn rendered_code_does_not_have_playground_stuff_in_html_when_disabled_in_config() {
let temp = DummyBook::new().build().unwrap();
let config = Config::from_str(
"
[output.html.playground]
runnable = false
",
)
.unwrap();
let md = MDBook::load_with_config(temp.path(), config).unwrap();
md.build().unwrap();
let nested = temp.path().join("book/first/nested.html");
let playground_class = vec![r#"class="playground""#];
assert_doesnt_contain_strings(nested, &playground_class);
}
#[test]
fn chapter_content_appears_in_rendered_document() {
let content = vec![

View file

@ -16,3 +16,15 @@ fn playground_on_rust_code() {
"##]],
);
}
// When the playground is disabled, there should be no playground class.
#[test]
fn disabled_playground() {
BookTest::from_dir("playground/disabled_playground").check_main_file(
"book/index.html",
str![[r##"
<h1 id="rust-sample"><a class="header" href="#rust-sample">Rust Sample</a></h1>
<pre><code class="language-rust">let x = 1;</code></pre>
"##]],
);
}

View file

@ -0,0 +1,5 @@
[book]
title = "playground_on_rust_code"
[output.html.playground]
runnable = false

View file

@ -0,0 +1,3 @@
# Summary
- [Rust Playground](./index.md)

View file

@ -0,0 +1,5 @@
# Rust Sample
```rust
let x = 1;
```