25 lines
984 B
Python
25 lines
984 B
Python
"""Tests for creative text formatting helpers."""
|
|
|
|
from src.usecase.creative.text_formatting import prepare_creative_text_html
|
|
|
|
|
|
def test_placeholder_is_replaced_with_custom_tag() -> None:
|
|
source = 'Подписывайтесь: {link}!'
|
|
assert prepare_creative_text_html(source) == 'Подписывайтесь: <a class="tg-link"></a>!'
|
|
|
|
|
|
def test_label_placeholder_is_wrapped() -> None:
|
|
source = 'Жми [сюда]{link} скорее'
|
|
assert prepare_creative_text_html(source) == 'Жми <a class="tg-link">сюда</a> скорее'
|
|
|
|
|
|
def test_placeholder_replacement_is_case_insensitive() -> None:
|
|
source = 'Первый {LINK}, второй {Link}.'
|
|
expected = 'Первый <a class="tg-link"></a>, второй <a class="tg-link"></a>.'
|
|
assert prepare_creative_text_html(source) == expected
|
|
|
|
|
|
def test_plain_html_left_untouched() -> None:
|
|
source = '<b>Жми</b> и <i>делись</i>'
|
|
assert prepare_creative_text_html(source) == source
|