Add minimal testing for the optional MathJax support

This commit is contained in:
Michal Budzynski 2017-06-25 00:39:57 +02:00
parent f214c7108f
commit db94b3d839
2 changed files with 18 additions and 1 deletions

View File

@ -15,7 +15,8 @@ fn do_not_overwrite_unspecified_config_values() {
let book = MDBook::new(dir.path()) let book = MDBook::new(dir.path())
.with_source("bar") .with_source("bar")
.with_destination("baz"); .with_destination("baz")
.with_mathjax_support(true);
assert_eq!(book.get_root(), dir.path()); assert_eq!(book.get_root(), dir.path());
assert_eq!(book.get_source(), dir.path().join("bar")); 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_root(), dir.path());
assert_eq!(book.get_source(), dir.path().join("bar")); assert_eq!(book.get_source(), dir.path().join("bar"));
assert_eq!(book.get_destination().unwrap(), dir.path().join("baz")); assert_eq!(book.get_destination().unwrap(), dir.path().join("baz"));
assert_eq!(book.get_mathjax_support(), true);
// Try with a partial config file // Try with a partial config file
let file_path = dir.path().join("book.toml"); 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_root(), dir.path());
assert_eq!(book.get_source(), dir.path().join("barbaz")); assert_eq!(book.get_source(), dir.path().join("barbaz"));
assert_eq!(book.get_destination().unwrap(), dir.path().join("baz")); assert_eq!(book.get_destination().unwrap(), dir.path().join("baz"));
assert_eq!(book.get_mathjax_support(), true);
} }

View File

@ -101,6 +101,20 @@ fn from_toml_output_html_curly_quotes() {
assert_eq!(htmlconfig.get_curly_quotes(), true); 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 // Tests that the `output.html.google-analytics` key is correctly parsed in the TOML config
#[test] #[test]
fn from_toml_output_html_google_analytics() { fn from_toml_output_html_google_analytics() {