aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tests/inheritance.rs
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-06-22 16:03:53 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-06-22 16:13:08 +0200
commit3d75bcfe786e23be26302c5d39658d75d19468b7 (patch)
tree6c5b4013d46b9525c27c266a7ad5871f80bfde6a /testing/tests/inheritance.rs
parent21edd48917baf57728adf7fd7693741f84b85402 (diff)
downloadaskama-3d75bcfe786e23be26302c5d39658d75d19468b7.tar.gz
askama-3d75bcfe786e23be26302c5d39658d75d19468b7.tar.bz2
askama-3d75bcfe786e23be26302c5d39658d75d19468b7.zip
Add test for 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 2fd69c6..9efbd62 100644
--- a/testing/tests/inheritance.rs
+++ b/testing/tests/inheritance.rs
@@ -79,3 +79,95 @@ fn test_nested_blocks() {
};
assert_eq!(t.render().unwrap(), "\ndurpy\n");
}
+
+#[derive(Template)]
+#[template(path = "deep-base.html")]
+struct DeepBaseTemplate {
+ year: u16,
+}
+
+#[derive(Template)]
+#[template(path = "deep-mid.html")]
+struct DeepMidTemplate {
+ _parent: DeepBaseTemplate,
+ title: String,
+}
+
+#[derive(Template)]
+#[template(path = "deep-kid.html")]
+struct DeepKidTemplate {
+ _parent: DeepMidTemplate,
+ item: String,
+}
+
+#[test]
+fn test_deep() {
+ let t = DeepKidTemplate {
+ _parent: DeepMidTemplate {
+ _parent: DeepBaseTemplate {
+ year: 2018,
+ },
+ title: "Test".into(),
+ },
+ 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>");
+ assert_eq!(t._parent.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>");
+ assert_eq!(t._parent._parent.render().unwrap(), "
+<html>
+ <head>
+
+ <style></style>
+
+ </head>
+ <body>
+
+ nav nav nav
+ Copyright 2018
+
+ </body>
+</html>");
+}