mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
* fix entity positioning in parse_entities() #413 * add tests and small fixes
This commit is contained in:
parent
d8c6214170
commit
17eb8a56d0
2 changed files with 42 additions and 9 deletions
25
tests/test_utils/test_text_decorations.py
Normal file
25
tests/test_utils/test_text_decorations.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
from aiogram.types import MessageEntity, MessageEntityType
|
||||
from aiogram.utils import text_decorations
|
||||
|
||||
|
||||
class TestTextDecorations:
|
||||
def test_unparse_entities_normal_text(self):
|
||||
assert text_decorations.markdown_decoration.unparse(
|
||||
"hi i'm bold and italic and still bold",
|
||||
entities=[
|
||||
MessageEntity(offset=3, length=34, type=MessageEntityType.BOLD),
|
||||
MessageEntity(offset=12, length=10, type=MessageEntityType.ITALIC),
|
||||
]
|
||||
) == "hi *i'm bold _and italic_\r and still bold*"
|
||||
|
||||
def test_unparse_entities_emoji_text(self):
|
||||
"""
|
||||
emoji is encoded as two chars in json
|
||||
"""
|
||||
assert text_decorations.markdown_decoration.unparse(
|
||||
"🚀 i'm bold and italic and still bold",
|
||||
entities=[
|
||||
MessageEntity(offset=3, length=34, type=MessageEntityType.BOLD),
|
||||
MessageEntity(offset=12, length=10, type=MessageEntityType.ITALIC),
|
||||
]
|
||||
) == "🚀 *i'm bold _and italic_\r and still bold*"
|
||||
Loading…
Add table
Add a link
Reference in a new issue