aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-06-22 16:20:49 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-06-22 16:20:49 +0200
commitb641f70adc3847e9a45a106d1b2ca97e597baae6 (patch)
treecbc98264f15dedc8178c8e79ab5b7d5371fa996a /testing
parent3219ed51e459b6c2980d5ba6ae589d2d9940dc2d (diff)
downloadaskama-b641f70adc3847e9a45a106d1b2ca97e597baae6.tar.gz
askama-b641f70adc3847e9a45a106d1b2ca97e597baae6.tar.bz2
askama-b641f70adc3847e9a45a106d1b2ca97e597baae6.zip
Add test for flattened deep inheritance
Diffstat (limited to '')
-rw-r--r--testing/tests/inheritance.rs92
1 files changed, 92 insertions, 0 deletions
diff --git a/testing/tests/inheritance.rs b/testing/tests/inheritance.rs
index 9efbd62..8b66a87 100644
--- a/testing/tests/inheritance.rs
+++ b/testing/tests/inheritance.rs
@@ -171,3 +171,95 @@ fn test_deep() {
</body>
</html>");
}
+
+#[derive(Template)]
+#[template(path = "deep-base.html")]
+struct FlatDeepBaseTemplate {
+ year: u16,
+}
+
+#[derive(Template)]
+#[template(path = "deep-mid.html")]
+struct FlatDeepMidTemplate {
+ title: String,
+}
+
+#[derive(Template)]
+#[template(path = "deep-kid.html")]
+struct FlatDeepKidTemplate {
+ item: String,
+}
+
+#[test]
+fn test_flat_deep() {
+ let t = FlatDeepKidTemplate {
+ item: "Foo".into(),
+ };
+
+ assert_eq!(t.render().unwrap(), "
+<html>
+ <head>
+
+ <script></script>
+
+ </head>
+ <body>
+
+ <div id=\"wrap\">
+ <section id=\"content\">
+
+ Foo Foo Foo
+
+ </section>
+ <section id=\"nav\">
+ nav nav nav
+ </section>
+ </div>
+
+ </body>
+</html>");
+
+ let t = FlatDeepMidTemplate {
+ title: "Test".into(),
+ };
+ assert_eq!(t.render().unwrap(), "
+<html>
+ <head>
+
+ Test
+
+ </head>
+ <body>
+
+ <div id=\"wrap\">
+ <section id=\"content\">
+
+ No content found
+
+ </section>
+ <section id=\"nav\">
+ nav nav nav
+ </section>
+ </div>
+
+ </body>
+</html>");
+
+ let t = FlatDeepBaseTemplate {
+ year: 2018,
+ };
+ assert_eq!(t.render().unwrap(), "
+<html>
+ <head>
+
+ <style></style>
+
+ </head>
+ <body>
+
+ nav nav nav
+ Copyright 2018
+
+ </body>
+</html>");
+}