From 3d75bcfe786e23be26302c5d39658d75d19468b7 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Fri, 22 Jun 2018 16:03:53 +0200 Subject: Add test for deep inheritance --- testing/tests/inheritance.rs | 92 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) (limited to 'testing/tests/inheritance.rs') 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(), " + + + + + + + + +
+
+ + Foo Foo Foo + +
+
+ nav nav nav +
+
+ + +"); + assert_eq!(t._parent.render().unwrap(), " + + + + Test + + + + +
+
+ + No content found + +
+
+ nav nav nav +
+
+ + +"); + assert_eq!(t._parent._parent.render().unwrap(), " + + + + + + + + + nav nav nav + Copyright 2018 + + +"); +} -- cgit