Add test for more complex template that uses built-in django filter.

This commit is contained in:
Emil Stenström 2019-11-24 11:10:09 +01:00
parent d91f014b4b
commit 701e1e3ac2
2 changed files with 20 additions and 0 deletions

View file

@ -0,0 +1,2 @@
Var1: <strong>{{ var1 }}</strong>
Var2 (uppercased): <strong>{{ var2|upper }}</strong>

View file

@ -46,3 +46,21 @@ class ComponentRegistryTest(SimpleTestCase):
<script type="text/javascript" src="script.js"></script>
<script type="text/javascript" src="script2.js"></script>
""").strip())
def test_component_with_filtered_template(self):
class FilteredComponent(component.Component):
def context(self, var1=None, var2=None):
return {
"var1": var1,
"var2": var2,
}
def template(self, context):
return "filtered_template.html"
comp = FilteredComponent()
self.assertHTMLEqual(comp.render(var1="test1", var2="test2"), dedent("""
Var1: <strong>test1</strong>
Var2 (uppercased): <strong>TEST2</strong>
""").lstrip())