From db94b3d8394851a515672c2617e999d55f8c7fea Mon Sep 17 00:00:00 2001 From: Michal Budzynski Date: Sun, 25 Jun 2017 00:39:57 +0200 Subject: [PATCH] Add minimal testing for the optional MathJax support --- tests/config.rs | 5 ++++- tests/tomlconfig.rs | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/config.rs b/tests/config.rs index 9fd95e60..fd9d86cc 100644 --- a/tests/config.rs +++ b/tests/config.rs @@ -15,7 +15,8 @@ fn do_not_overwrite_unspecified_config_values() { let book = MDBook::new(dir.path()) .with_source("bar") - .with_destination("baz"); + .with_destination("baz") + .with_mathjax_support(true); assert_eq!(book.get_root(), dir.path()); assert_eq!(book.get_source(), dir.path().join("bar")); @@ -27,6 +28,7 @@ fn do_not_overwrite_unspecified_config_values() { assert_eq!(book.get_root(), dir.path()); assert_eq!(book.get_source(), dir.path().join("bar")); assert_eq!(book.get_destination().unwrap(), dir.path().join("baz")); + assert_eq!(book.get_mathjax_support(), true); // Try with a partial config file let file_path = dir.path().join("book.toml"); @@ -39,5 +41,6 @@ fn do_not_overwrite_unspecified_config_values() { assert_eq!(book.get_root(), dir.path()); assert_eq!(book.get_source(), dir.path().join("barbaz")); assert_eq!(book.get_destination().unwrap(), dir.path().join("baz")); + assert_eq!(book.get_mathjax_support(), true); } diff --git a/tests/tomlconfig.rs b/tests/tomlconfig.rs index 0ff62ada..a751b359 100644 --- a/tests/tomlconfig.rs +++ b/tests/tomlconfig.rs @@ -101,6 +101,20 @@ fn from_toml_output_html_curly_quotes() { assert_eq!(htmlconfig.get_curly_quotes(), true); } +// Tests that the `output.html.mathjax-support` key is correctly parsed in the TOML config +#[test] +fn from_toml_output_html_mathjax_support() { + let toml = r#"[output.html] + mathjax-support = true"#; + + let parsed = TomlConfig::from_toml(&toml).expect("This should parse"); + let config = BookConfig::from_tomlconfig("root", parsed); + + let htmlconfig = config.get_html_config().expect("There should be an HtmlConfig"); + + assert_eq!(htmlconfig.get_mathjax_support(), true); +} + // Tests that the `output.html.google-analytics` key is correctly parsed in the TOML config #[test] fn from_toml_output_html_google_analytics() {