From b641f70adc3847e9a45a106d1b2ca97e597baae6 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Fri, 22 Jun 2018 16:20:49 +0200 Subject: Add test for flattened deep inheritance --- testing/tests/inheritance.rs | 92 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) (limited to 'testing/tests') 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() { "); } + +#[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(), " + + + + + + + + +
+
+ + Foo Foo Foo + +
+
+ nav nav nav +
+
+ + +"); + + let t = FlatDeepMidTemplate { + title: "Test".into(), + }; + assert_eq!(t.render().unwrap(), " + + + + Test + + + + +
+
+ + No content found + +
+
+ nav nav nav +
+
+ + +"); + + let t = FlatDeepBaseTemplate { + year: 2018, + }; + assert_eq!(t.render().unwrap(), " + + + + + + + + + nav nav nav + Copyright 2018 + + +"); +} -- cgit