@@ -2,37 +2,15 @@ mod dummy_book;
2
2
3
3
use crate :: dummy_book:: { assert_contains_strings, DummyBook } ;
4
4
5
- use anyhow:: Context ;
6
5
use mdbook:: config:: Config ;
7
- use mdbook:: errors:: * ;
8
6
use mdbook:: MDBook ;
9
7
use pretty_assertions:: assert_eq;
10
- use select:: document:: Document ;
11
- use select:: predicate:: { Attr , Class , Name , Predicate } ;
12
8
use std:: ffi:: OsStr ;
13
9
use std:: fs;
14
10
use std:: path:: Path ;
15
11
use walkdir:: { DirEntry , WalkDir } ;
16
12
17
13
const 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
- ] ;
36
14
37
15
#[ test]
38
16
fn by_default_mdbook_generates_rendered_content_in_the_book_directory ( ) {
@@ -120,39 +98,6 @@ fn entry_ends_with(entry: &DirEntry, ending: &str) -> bool {
120
98
entry. file_name ( ) . to_string_lossy ( ) . ends_with ( ending)
121
99
}
122
100
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
-
156
101
#[ test]
157
102
fn example_book_can_build ( ) {
158
103
let example_book_dir = dummy_book:: new_copy_of_example_book ( ) . unwrap ( ) ;
0 commit comments