add tests
This commit is contained in:
parent
b85c3035fe
commit
0dca4d9b9f
|
@ -815,6 +815,22 @@ mod tests {
|
||||||
assert_eq!(got.html_config().unwrap(), html_should_be);
|
assert_eq!(got.html_config().unwrap(), html_should_be);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn disable_runnable() {
|
||||||
|
let src = r#"
|
||||||
|
[book]
|
||||||
|
title = "Some Book"
|
||||||
|
description = "book book book"
|
||||||
|
authors = ["Shogo Takata"]
|
||||||
|
|
||||||
|
[output.html.playground]
|
||||||
|
runnable = false
|
||||||
|
"#;
|
||||||
|
|
||||||
|
let got = Config::from_str(src).unwrap();
|
||||||
|
assert_eq!(got.html_config().unwrap().playground.runnable, false);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn edition_2015() {
|
fn edition_2015() {
|
||||||
let src = r#"
|
let src = r#"
|
||||||
|
|
|
@ -17,6 +17,7 @@ use std::ffi::OsStr;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::{Component, Path, PathBuf};
|
use std::path::{Component, Path, PathBuf};
|
||||||
|
use std::str::FromStr;
|
||||||
use tempfile::Builder as TempFileBuilder;
|
use tempfile::Builder as TempFileBuilder;
|
||||||
use walkdir::{DirEntry, WalkDir};
|
use walkdir::{DirEntry, WalkDir};
|
||||||
|
|
||||||
|
@ -150,6 +151,25 @@ fn rendered_code_has_playground_stuff() {
|
||||||
assert_contains_strings(book_js, &[".playground"]);
|
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();
|
||||||
|
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]
|
#[test]
|
||||||
fn anchors_include_text_between_but_not_anchor_comments() {
|
fn anchors_include_text_between_but_not_anchor_comments() {
|
||||||
let temp = DummyBook::new().build().unwrap();
|
let temp = DummyBook::new().build().unwrap();
|
||||||
|
|
Loading…
Reference in New Issue