From 701e1e3ac23d7f4cc2e98aad6608f0985763dfc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Stenstr=C3=B6m?= Date: Sun, 24 Nov 2019 11:10:09 +0100 Subject: [PATCH] Add test for more complex template that uses built-in django filter. --- tests/templates/filtered_template.html | 2 ++ tests/test_component.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/templates/filtered_template.html diff --git a/tests/templates/filtered_template.html b/tests/templates/filtered_template.html new file mode 100644 index 00000000..1730d774 --- /dev/null +++ b/tests/templates/filtered_template.html @@ -0,0 +1,2 @@ +Var1: {{ var1 }} +Var2 (uppercased): {{ var2|upper }} diff --git a/tests/test_component.py b/tests/test_component.py index 81d9820b..6328a1c3 100644 --- a/tests/test_component.py +++ b/tests/test_component.py @@ -46,3 +46,21 @@ class ComponentRegistryTest(SimpleTestCase): """).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: test1 + Var2 (uppercased): TEST2 + """).lstrip())