| 1 |
//! Tests for the index preprocessor. |
| 2 |
|
| 3 |
use crate::prelude::*; |
| 4 |
|
| 5 |
// Checks basic README to index.html conversion. |
| 6 |
#[test] |
| 7 |
fn readme_to_index() { |
| 8 |
let mut test = BookTest::from_dir("index/basic_readme"); |
| 9 |
test.check_main_file( |
| 10 |
"book/index.html", |
| 11 |
str![[r##"<h1 id="intro"><a class="header" href="#intro">Intro</a></h1>"##]], |
| 12 |
) |
| 13 |
.check_main_file( |
| 14 |
"book/first/index.html", |
| 15 |
str![[r##"<h1 id="first"><a class="header" href="#first">First</a></h1>"##]], |
| 16 |
) |
| 17 |
.check_main_file( |
| 18 |
"book/second/index.html", |
| 19 |
str![[r##"<h1 id="second"><a class="header" href="#second">Second</a></h1>"##]], |
| 20 |
) |
| 21 |
.check_toc_js(str![[r#" |
| 22 |
<ol class="chapter"> |
| 23 |
<li class="chapter-item expanded "> |
| 24 |
<span class="chapter-link-wrapper"> |
| 25 |
<a href="index.html">Intro</a> |
| 26 |
</span> |
| 27 |
</li> |
| 28 |
<li class="chapter-item expanded "> |
| 29 |
<span class="chapter-link-wrapper"> |
| 30 |
<a href="first/index.html"> |
| 31 |
<strong aria-hidden="true">1.</strong> First</a> |
| 32 |
</span> |
| 33 |
</li> |
| 34 |
<li class="chapter-item expanded "> |
| 35 |
<span class="chapter-link-wrapper"> |
| 36 |
<a href="second/index.html"> |
| 37 |
<strong aria-hidden="true">2.</strong> Second</a> |
| 38 |
</span> |
| 39 |
</li> |
| 40 |
</ol> |
| 41 |
"#]]); |
| 42 |
assert!(test.dir.join("book/index.html").exists()); |
| 43 |
assert!(!test.dir.join("book/README.html").exists()); |
| 44 |
} |