mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-11 15:52:21 -05:00
78 lines
2.5 KiB
Python
78 lines
2.5 KiB
Python
import pytest
|
|
|
|
from notifications_utils.field import Field
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
(
|
|
"content",
|
|
"values",
|
|
"expected_stripped",
|
|
"expected_escaped",
|
|
"expected_passthrough",
|
|
),
|
|
[
|
|
(
|
|
"string <em>with</em> html",
|
|
{},
|
|
"string with html",
|
|
"string <em>with</em> html",
|
|
"string <em>with</em> html",
|
|
),
|
|
(
|
|
"string ((<em>with</em>)) html",
|
|
{},
|
|
"string <span class='placeholder'>((with))</span> html",
|
|
"string <span class='placeholder'>((<em>with</em>))</span> html",
|
|
"string <span class='placeholder'>((<em>with</em>))</span> html",
|
|
),
|
|
(
|
|
"string ((placeholder)) html",
|
|
{"placeholder": "<em>without</em>"},
|
|
"string without html",
|
|
"string <em>without</em> html",
|
|
"string <em>without</em> html",
|
|
),
|
|
(
|
|
"string ((<em>conditional</em>??<em>placeholder</em>)) html",
|
|
{},
|
|
"string <span class='placeholder-conditional'>((conditional??</span>placeholder)) html",
|
|
(
|
|
"string "
|
|
"<span class='placeholder-conditional'>"
|
|
"((<em>conditional</em>??</span>"
|
|
"<em>placeholder</em>)) "
|
|
"html"
|
|
),
|
|
(
|
|
"string "
|
|
"<span class='placeholder-conditional'>"
|
|
"((<em>conditional</em>??</span>"
|
|
"<em>placeholder</em>)) "
|
|
"html"
|
|
),
|
|
),
|
|
(
|
|
"string ((conditional??<em>placeholder</em>)) html",
|
|
{"conditional": True},
|
|
"string placeholder html",
|
|
"string <em>placeholder</em> html",
|
|
"string <em>placeholder</em> html",
|
|
),
|
|
(
|
|
"string & entity",
|
|
{},
|
|
"string & entity",
|
|
"string & entity",
|
|
"string & entity",
|
|
),
|
|
],
|
|
)
|
|
def test_field_handles_html(
|
|
content, values, expected_stripped, expected_escaped, expected_passthrough
|
|
):
|
|
assert str(Field(content, values)) == expected_stripped
|
|
assert str(Field(content, values, html="strip")) == expected_stripped
|
|
assert str(Field(content, values, html="escape")) == expected_escaped
|
|
assert str(Field(content, values, html="passthrough")) == expected_passthrough
|