Skip to content

Commit efc5ee4

Browse files
committed
Migrate check_first_toc_level to BookTest
1 parent 14d412b commit efc5ee4

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

tests/rendered_output.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -169,29 +169,6 @@ fn toc_fallback_html() -> Result<Document> {
169169
Ok(Document::from(html.as_str()))
170170
}
171171

172-
#[test]
173-
fn check_first_toc_level() {
174-
let doc = toc_js_html().unwrap();
175-
let mut should_be = Vec::from(TOC_TOP_LEVEL);
176-
177-
should_be.extend(TOC_SECOND_LEVEL);
178-
should_be.sort_unstable();
179-
180-
let pred = descendants!(
181-
Class("chapter"),
182-
Name("li"),
183-
Name("a").and(Class("toggle").not())
184-
);
185-
186-
let mut children: Vec<_> = doc
187-
.find(pred)
188-
.map(|elem| elem.text().trim().to_string())
189-
.collect();
190-
children.sort();
191-
192-
assert_eq!(children, should_be);
193-
}
194-
195172
#[test]
196173
fn check_spacers() {
197174
let doc = toc_js_html().unwrap();

tests/testsuite/toc.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ use crate::prelude::*;
44
use select::document::Document;
55
use select::predicate::{Class, Name, Predicate};
66

7+
const TOC_TOP_LEVEL: &[&str] = &[
8+
"1. With Readme",
9+
"3. Deep Nest 1",
10+
"Prefix 1",
11+
"Prefix 2",
12+
"Suffix 1",
13+
"Suffix 2",
14+
];
715
const TOC_SECOND_LEVEL: &[&str] = &[
816
"1.1. Nested Index",
917
"1.2. Nested two",
@@ -53,3 +61,26 @@ fn check_second_toc_level() {
5361

5462
assert_eq!(children_of_children, should_be);
5563
}
64+
65+
#[test]
66+
fn check_first_toc_level() {
67+
let doc = toc_js_html();
68+
let mut should_be = Vec::from(TOC_TOP_LEVEL);
69+
70+
should_be.extend(TOC_SECOND_LEVEL);
71+
should_be.sort_unstable();
72+
73+
let pred = descendants!(
74+
Class("chapter"),
75+
Name("li"),
76+
Name("a").and(Class("toggle").not())
77+
);
78+
79+
let mut children: Vec<_> = doc
80+
.find(pred)
81+
.map(|elem| elem.text().trim().to_string())
82+
.collect();
83+
children.sort();
84+
85+
assert_eq!(children, should_be);
86+
}

0 commit comments

Comments
 (0)