mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-13 18:43:53 +00:00
Fixed nested hashtag, cashtag and email entnties parsing (#1263)
* Fixed nested hashtag, cashtag and email message entities not being parsed correctly when these entities are inside another entity. * Tests coverage
This commit is contained in:
parent
020db29e6d
commit
a80031509e
3 changed files with 42 additions and 1 deletions
|
|
@ -113,6 +113,14 @@ class TestTextDecoration:
|
|||
):
|
||||
assert decorator.apply_entity(entity, "test") == result
|
||||
|
||||
def test_unknown_apply_entity(self):
|
||||
assert (
|
||||
html_decoration.apply_entity(
|
||||
MessageEntity(type="unknown", offset=0, length=5), "<test>"
|
||||
)
|
||||
== "<test>"
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"decorator,before,after",
|
||||
[
|
||||
|
|
@ -243,6 +251,33 @@ class TestTextDecoration:
|
|||
[MessageEntity(type="bold", offset=0, length=8, url=None, user=None)],
|
||||
"<b>👋🏾 Hi!</b>",
|
||||
],
|
||||
[
|
||||
html_decoration,
|
||||
"#test",
|
||||
[
|
||||
MessageEntity(type="hashtag", offset=0, length=5),
|
||||
MessageEntity(type="bold", offset=0, length=5),
|
||||
],
|
||||
"<b>#test</b>",
|
||||
],
|
||||
[
|
||||
html_decoration,
|
||||
"$TEST",
|
||||
[
|
||||
MessageEntity(type="cashtag", offset=0, length=5),
|
||||
MessageEntity(type="bold", offset=0, length=5),
|
||||
],
|
||||
"<b>$TEST</b>",
|
||||
],
|
||||
[
|
||||
html_decoration,
|
||||
"test@example.com",
|
||||
[
|
||||
MessageEntity(type="email", offset=0, length=16),
|
||||
MessageEntity(type="bold", offset=0, length=16),
|
||||
],
|
||||
"<b>test@example.com</b>",
|
||||
],
|
||||
],
|
||||
)
|
||||
def test_unparse(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue