mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-09 13:29:47 +00:00
Fix unparsing of entities that are together
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
Tests for `telethon.extensions.html`.
|
||||
"""
|
||||
from telethon.extensions import html
|
||||
from telethon.tl.types import MessageEntityBold, MessageEntityTextUrl
|
||||
from telethon.tl.types import MessageEntityBold, MessageEntityItalic, MessageEntityTextUrl
|
||||
|
||||
|
||||
def test_entity_edges():
|
||||
@@ -36,3 +36,18 @@ def test_trailing_malformed_entities():
|
||||
entities = [MessageEntityTextUrl(offset=2, length=43, url='https://example.com')]
|
||||
result = html.unparse(text, entities)
|
||||
assert result == '🏆<a href="https://example.com">Telegram Official Android Challenge is over🏆</a>'
|
||||
|
||||
|
||||
def test_entities_together():
|
||||
"""
|
||||
Test that an entity followed immediately by a different one behaves well.
|
||||
"""
|
||||
original = '<strong>⚙️</strong><em>Settings</em>'
|
||||
stripped = '⚙️Settings'
|
||||
|
||||
text, entities = html.parse(original)
|
||||
assert text == stripped
|
||||
assert entities == [MessageEntityBold(0, 2), MessageEntityItalic(2, 8)]
|
||||
|
||||
text = html.unparse(text, entities)
|
||||
assert text == original
|
||||
|
Reference in New Issue
Block a user