Fix mdbook-core book tests
These tests were moved in https://github.com/rust-lang/mdBook/pull/2766, but the `mod tests` was missing. This fixes this missing `mod`, and updates the tests so that they pass.
This commit is contained in:
parent
6be8e526d6
commit
24c7ffcd62
2 changed files with 100 additions and 98 deletions
|
|
@ -6,6 +6,9 @@ use std::fmt::{self, Display, Formatter};
|
|||
use std::ops::{Deref, DerefMut};
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
/// A tree structure representing a book.
|
||||
///
|
||||
/// For the moment a book is just a collection of [`BookItems`] which are
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ fn section_number_has_correct_dotted_representation() {
|
|||
|
||||
#[test]
|
||||
fn book_iter_iterates_over_sequential_items() {
|
||||
let sections = vec![
|
||||
let items = vec![
|
||||
BookItem::Chapter(Chapter {
|
||||
name: String::from("Chapter 1"),
|
||||
content: String::from("# Chapter 1"),
|
||||
|
|
@ -24,7 +24,7 @@ fn section_number_has_correct_dotted_representation() {
|
|||
}),
|
||||
BookItem::Separator,
|
||||
];
|
||||
let book = Book::new_with_sections(sections);
|
||||
let book = Book::new_with_items(items);
|
||||
|
||||
let should_be: Vec<_> = book.sections.iter().collect();
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ fn section_number_has_correct_dotted_representation() {
|
|||
|
||||
#[test]
|
||||
fn for_each_mut_visits_all_items() {
|
||||
let sections = vec![
|
||||
let items = vec![
|
||||
BookItem::Chapter(Chapter {
|
||||
name: String::from("Chapter 1"),
|
||||
content: String::from("# Chapter 1"),
|
||||
|
|
@ -61,7 +61,7 @@ fn section_number_has_correct_dotted_representation() {
|
|||
}),
|
||||
BookItem::Separator,
|
||||
];
|
||||
let mut book = Book::new_with_sections(sections);
|
||||
let mut book = Book::new_with_items(items);
|
||||
|
||||
let num_items = book.iter().count();
|
||||
let mut visited = 0;
|
||||
|
|
@ -73,7 +73,7 @@ fn section_number_has_correct_dotted_representation() {
|
|||
|
||||
#[test]
|
||||
fn iterate_over_nested_book_items() {
|
||||
let sections = vec![
|
||||
let items = vec![
|
||||
BookItem::Chapter(Chapter {
|
||||
name: String::from("Chapter 1"),
|
||||
content: String::from("# Chapter 1"),
|
||||
|
|
@ -99,7 +99,7 @@ fn section_number_has_correct_dotted_representation() {
|
|||
}),
|
||||
BookItem::Separator,
|
||||
];
|
||||
let book = Book::new_with_sections(sections);
|
||||
let book = Book::new_with_items(items);
|
||||
|
||||
let got: Vec<_> = book.iter().collect();
|
||||
|
||||
|
|
@ -121,4 +121,3 @@ fn section_number_has_correct_dotted_representation() {
|
|||
|
||||
assert_eq!(chapter_names, should_be);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue