]>
git.proxmox.com Git - rustc.git/blob - src/vendor/mdbook/tests/jsonconfig.rs
2 use mdbook
::config
::BookConfig
;
3 use mdbook
::config
::jsonconfig
::JsonConfig
;
5 use std
::path
::PathBuf
;
7 // Tests that the `src` key is correctly parsed in the JSON config
9 fn from_json_source() {
14 let parsed
= JsonConfig
::from_json(json
).expect("This should parse");
15 let config
= BookConfig
::from_jsonconfig("root", parsed
);
17 assert_eq
!(config
.get_source(), PathBuf
::from("root/source"));
20 // Tests that the `title` key is correctly parsed in the JSON config
22 fn from_json_title() {
27 let parsed
= JsonConfig
::from_json(json
).expect("This should parse");
28 let config
= BookConfig
::from_jsonconfig("root", parsed
);
30 assert_eq
!(config
.get_title(), "Some title");
33 // Tests that the `description` key is correctly parsed in the JSON config
35 fn from_json_description() {
37 "description": "This is a description"
40 let parsed
= JsonConfig
::from_json(json
).expect("This should parse");
41 let config
= BookConfig
::from_jsonconfig("root", parsed
);
43 assert_eq
!(config
.get_description(), "This is a description");
46 // Tests that the `author` key is correctly parsed in the JSON config
48 fn from_json_author() {
53 let parsed
= JsonConfig
::from_json(json
).expect("This should parse");
54 let config
= BookConfig
::from_jsonconfig("root", parsed
);
56 assert_eq
!(config
.get_authors(), &[String
::from("John Doe")]);
59 // Tests that the `dest` key is correctly parsed in the JSON config
61 fn from_json_destination() {
66 let parsed
= JsonConfig
::from_json(json
).expect("This should parse");
67 let config
= BookConfig
::from_jsonconfig("root", parsed
);
69 let htmlconfig
= config
.get_html_config();
71 assert_eq
!(htmlconfig
.get_destination(), PathBuf
::from("root/htmlbook"));
74 // Tests that the `theme_path` key is correctly parsed in the JSON config
76 fn from_json_output_html_theme() {
81 let parsed
= JsonConfig
::from_json(json
).expect("This should parse");
82 let config
= BookConfig
::from_jsonconfig("root", parsed
);
84 let htmlconfig
= config
.get_html_config();
86 assert_eq
!(htmlconfig
.get_theme(), &PathBuf
::from("root/theme"));