Migrate custom_header_attributes to BookTest
This commit is contained in:
parent
74e01ea6e3
commit
6904653a82
5 changed files with 21 additions and 16 deletions
|
|
@ -829,22 +829,6 @@ fn custom_fonts() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn custom_header_attributes() {
|
|
||||||
let temp = DummyBook::new().build().unwrap();
|
|
||||||
let md = MDBook::load(temp.path()).unwrap();
|
|
||||||
md.build().unwrap();
|
|
||||||
|
|
||||||
let contents = temp.path().join("book/first/heading-attributes.html");
|
|
||||||
|
|
||||||
let summary_strings = &[
|
|
||||||
r##"<h1 id="attrs"><a class="header" href="#attrs">Heading Attributes</a></h1>"##,
|
|
||||||
r##"<h2 id="heading-with-classes" class="class1 class2"><a class="header" href="#heading-with-classes">Heading with classes</a></h2>"##,
|
|
||||||
r##"<h2 id="both" class="class1 class2"><a class="header" href="#both">Heading with id and classes</a></h2>"##,
|
|
||||||
];
|
|
||||||
assert_contains_strings(&contents, summary_strings);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn with_no_source_path() {
|
fn with_no_source_path() {
|
||||||
// Test for a regression where search would fail if source_path is None.
|
// Test for a regression where search would fail if source_path is None.
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,17 @@
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
|
// Checks custom header id and classes.
|
||||||
|
#[test]
|
||||||
|
fn custom_header_attributes() {
|
||||||
|
BookTest::from_dir("markdown/custom_header_attributes")
|
||||||
|
.check_main_file("book/custom_header_attributes.html", str![[r##"
|
||||||
|
<h1 id="attrs"><a class="header" href="#attrs">Heading Attributes</a></h1>
|
||||||
|
<h2 id="heading-with-classes" class="class1 class2"><a class="header" href="#heading-with-classes">Heading with classes</a></h2>
|
||||||
|
<h2 id="both" class="class1 class2"><a class="header" href="#both">Heading with id and classes</a></h2>
|
||||||
|
"##]]);
|
||||||
|
}
|
||||||
|
|
||||||
// Test for a variety of footnote renderings.
|
// Test for a variety of footnote renderings.
|
||||||
#[test]
|
#[test]
|
||||||
fn footnotes() {
|
fn footnotes() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
[book]
|
||||||
|
title = "custom_header_attributes"
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Summary
|
||||||
|
|
||||||
|
- [Heading Attributes](./custom_header_attributes.md)
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Heading Attributes {#attrs}
|
||||||
|
|
||||||
|
## Heading with classes {.class1 .class2}
|
||||||
|
|
||||||
|
## Heading with id and classes {#both .class1 .class2}
|
||||||
Loading…
Add table
Reference in a new issue