diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 66911e16..8bd2751c 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -128,6 +128,38 @@ fn check_correct_cross_links_in_nested_dir() { } } +#[test] +fn run_mdbook_init() { + let created_files = vec!["book", "src", "src/SUMMARY.md", "src/chapter_1.md"]; + + let temp = TempDir::new("mdbook").unwrap(); + for file in &created_files { + assert!(!temp.path().join(file).exists()); + } + + let mut md = MDBook::new(temp.path()); + md.init().unwrap(); + + for file in &created_files { + assert!(temp.path().join(file).exists(), "{} doesn't exist", file); + } +} + +#[test] +fn rendered_code_has_playpen_stuff() { + let temp = create_book(true); + let mut md = MDBook::new(temp.path()); + md.build().unwrap(); + + let nested = temp.path().join("book/first/nested.html"); + let playpen_class = vec![r#"class="playpen""#]; + + assert_contains_strings(nested, &playpen_class); + + let book_js = temp.path().join("book/book.js"); + assert_contains_strings(book_js, &[".playpen"]); +} + /// Create a dummy book in a temporary directory, using the contents of /// `SUMMARY_MD` as a guide. ///