From fb0a0154610e0e1d0e065e7be328b8dde27ed53f Mon Sep 17 00:00:00 2001 From: Kevin Carrogan Date: Wed, 18 Dec 2024 15:11:06 +0000 Subject: [PATCH] Add tests for variable highlight --- unit_tests/caseworker/test_template_tags.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/unit_tests/caseworker/test_template_tags.py b/unit_tests/caseworker/test_template_tags.py index c3d227f2a9..f008957fd0 100644 --- a/unit_tests/caseworker/test_template_tags.py +++ b/unit_tests/caseworker/test_template_tags.py @@ -1,6 +1,7 @@ from core.builtins import custom_tags from caseworker.core.constants import SLA_CIRCUMFERENCE +from caseworker.letter_templates.templatetags.variable_highlight import variable_highlight import pytest @@ -60,3 +61,20 @@ def test_sla_colour(remaining, unit, colour): def test_sla_colour_missing_unit(): with pytest.raises(ValueError): custom_tags.sla_colour(10, "") + + +@pytest.mark.parametrize( + "input, expected", + ( + ("just text", "just text"), + ("with {{ variable }}", 'with {{ variable }}'), + ( + "with {% another_variable %}", + 'with {% another_variable %}', + ), + ("Link", "Link"), + ("", "<script>alert()</script>"), + ), +) +def test_variable_highlight(input, expected): + assert variable_highlight(input) == expected