| 1079 |
1079 |
|
assert!(html.find("name=\"a\"") < html.find("name=\"b\""));
|
| 1080 |
1080 |
|
}
|
| 1081 |
1081 |
|
|
|
1082 |
+ |
#[test]
|
|
1083 |
+ |
fn a_document_wraps_markup_the_renderer_did_not_write() {
|
|
1084 |
+ |
// The path a host on hand-written templates takes: one head, emitted here,
|
|
1085 |
+ |
// around a body it rendered itself.
|
|
1086 |
+ |
let shell = Shell::default().layered(["base"]).styled("/style.css");
|
|
1087 |
+ |
let html = shell.document("Console", "<main>hand-written</main>");
|
|
1088 |
+ |
|
|
1089 |
+ |
assert!(html.starts_with("<!doctype html><html lang=\"en\">"));
|
|
1090 |
+ |
assert!(html.contains("<title>Console</title>"));
|
|
1091 |
+ |
assert!(html.contains("<main>hand-written</main>"));
|
|
1092 |
+ |
assert!(html.ends_with("</body></html>"));
|
|
1093 |
+ |
}
|
|
1094 |
+ |
|
|
1095 |
+ |
#[test]
|
|
1096 |
+ |
fn a_document_states_the_layers_before_the_sheets_like_a_screen_does() {
|
|
1097 |
+ |
// The whole reason a template would take the shell. If these two paths
|
|
1098 |
+ |
// disagree on layer order, the described and the Askama halves of one app
|
|
1099 |
+ |
// cascade differently.
|
|
1100 |
+ |
let shell = Shell::default().layered(["base"]).styled("/style.css");
|
|
1101 |
+ |
let html = shell.document("Console", "<main>x</main>");
|
|
1102 |
+ |
|
|
1103 |
+ |
let stmt = html.find("@layer makeover, base;").expect("the order is stated");
|
|
1104 |
+ |
let sheet = html.find("/style.css").expect("the sheet is linked");
|
|
1105 |
+ |
let body = html.find("<main>").expect("the body is placed");
|
|
1106 |
+ |
assert!(stmt < sheet);
|
|
1107 |
+ |
assert!(sheet < body);
|
|
1108 |
+ |
}
|
|
1109 |
+ |
|
|
1110 |
+ |
#[test]
|
|
1111 |
+ |
fn a_documents_body_tag_is_the_shells_own() {
|
|
1112 |
+ |
// The morph registration and the body classes are the shell's on both
|
|
1113 |
+ |
// paths, so a template does not have to remember either.
|
|
1114 |
+ |
let shell = Shell {
|
|
1115 |
+ |
body_class: Some("console".into()),
|
|
1116 |
+ |
..Shell::default()
|
|
1117 |
+ |
};
|
|
1118 |
+ |
let html = shell.document("Console", "x");
|
|
1119 |
+ |
|
|
1120 |
+ |
assert!(html.contains("<body hx-ext=\"morph\" class=\"console\">x</body>"));
|
|
1121 |
+ |
}
|
|
1122 |
+ |
|
| 1082 |
1123 |
|
#[test]
|
| 1083 |
1124 |
|
fn a_nested_region_renders_inside_its_parent() {
|
| 1084 |
1125 |
|
let screen =
|