Migrate rendered_code_has_playground_stuff to BookTest
This commit is contained in:
parent
8c8f0a4dbf
commit
20d42a53d3
6 changed files with 29 additions and 15 deletions
|
|
@ -93,21 +93,6 @@ fn check_correct_relative_links_in_print_page() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rendered_code_has_playground_stuff() {
|
||||
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 playground_class = vec![r#"class="playground""#];
|
||||
|
||||
assert_contains_strings(nested, &playground_class);
|
||||
|
||||
let book_js = temp.path().join("book/book.js");
|
||||
assert_contains_strings(book_js, &[".playground"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rendered_code_does_not_have_playground_stuff_in_html_when_disabled_in_config() {
|
||||
let temp = DummyBook::new().build().unwrap();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ mod includes;
|
|||
mod index;
|
||||
mod init;
|
||||
mod markdown;
|
||||
mod playground;
|
||||
|
||||
mod prelude {
|
||||
pub use crate::book_test::BookTest;
|
||||
|
|
|
|||
18
tests/testsuite/playground.rs
Normal file
18
tests/testsuite/playground.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
//! Tests for Rust playground support.
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
// Verifies that a rust codeblock gets the playground class.
|
||||
#[test]
|
||||
fn playground_on_rust_code() {
|
||||
BookTest::from_dir("playground/playground_on_rust_code").check_main_file(
|
||||
"book/index.html",
|
||||
str![[r##"
|
||||
<h1 id="rust-sample"><a class="header" href="#rust-sample">Rust Sample</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>
|
||||
"##]],
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
[book]
|
||||
title = "playground_on_rust_code"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# Summary
|
||||
|
||||
- [Rust Playground](./index.md)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# Rust Sample
|
||||
|
||||
```rust
|
||||
let x = 1;
|
||||
```
|
||||
Loading…
Add table
Reference in a new issue