@@ -2,37 +2,15 @@ mod dummy_book;
22
33use crate :: dummy_book:: { assert_contains_strings, DummyBook } ;
44
5- use anyhow:: Context ;
65use mdbook:: config:: Config ;
7- use mdbook:: errors:: * ;
86use mdbook:: MDBook ;
97use pretty_assertions:: assert_eq;
10- use select:: document:: Document ;
11- use select:: predicate:: { Attr , Class , Name , Predicate } ;
128use std:: ffi:: OsStr ;
139use std:: fs;
1410use std:: path:: Path ;
1511use walkdir:: { DirEntry , WalkDir } ;
1612
1713const BOOK_ROOT : & str = concat ! ( env!( "CARGO_MANIFEST_DIR" ) , "/tests/dummy_book" ) ;
18- const TOC_TOP_LEVEL : & [ & str ] = & [
19- "1. First Chapter" ,
20- "2. Second Chapter" ,
21- "Conclusion" ,
22- "Dummy Book" ,
23- "Introduction" ,
24- ] ;
25- const TOC_SECOND_LEVEL : & [ & str ] = & [
26- "1.1. Nested Chapter" ,
27- "1.2. Includes" ,
28- "1.3. Recursive" ,
29- "1.4. Markdown" ,
30- "1.5. Unicode" ,
31- "1.6. No Headers" ,
32- "1.7. Duplicate Headers" ,
33- "1.8. Heading Attributes" ,
34- "2.1. Nested Chapter" ,
35- ] ;
3614
3715#[ test]
3816fn by_default_mdbook_generates_rendered_content_in_the_book_directory ( ) {
@@ -120,39 +98,6 @@ fn entry_ends_with(entry: &DirEntry, ending: &str) -> bool {
12098 entry. file_name ( ) . to_string_lossy ( ) . ends_with ( ending)
12199}
122100
123- /// Read the TOC fallback (`book/toc.html`) HTML and expose it as a DOM which we
124- /// can search with the `select` crate
125- fn toc_fallback_html ( ) -> Result < Document > {
126- let temp = DummyBook :: new ( )
127- . build ( )
128- . with_context ( || "Couldn't create the dummy book" ) ?;
129- MDBook :: load ( temp. path ( ) ) ?
130- . build ( )
131- . with_context ( || "Book building failed" ) ?;
132-
133- let toc_path = temp. path ( ) . join ( "book" ) . join ( "toc.html" ) ;
134- let html = fs:: read_to_string ( toc_path) . with_context ( || "Unable to read index.html" ) ?;
135- Ok ( Document :: from ( html. as_str ( ) ) )
136- }
137-
138- // don't use target="_parent" in IFRAME
139- #[ test]
140- fn check_link_target_fallback ( ) {
141- let doc = toc_fallback_html ( ) . unwrap ( ) ;
142-
143- let num_parent_links = doc
144- . find (
145- Class ( "chapter" )
146- . descendant ( Name ( "li" ) )
147- . descendant ( Name ( "a" ) . and ( Attr ( "target" , "_parent" ) ) ) ,
148- )
149- . count ( ) ;
150- assert_eq ! (
151- num_parent_links,
152- TOC_TOP_LEVEL . len( ) + TOC_SECOND_LEVEL . len( )
153- ) ;
154- }
155-
156101#[ test]
157102fn example_book_can_build ( ) {
158103 let example_book_dir = dummy_book:: new_copy_of_example_book ( ) . unwrap ( ) ;
0 commit comments