@@ -98,16 +98,46 @@ def test_parse_entities(self):
9898 {entity : 'http://google.com' ,
9999 entity_2 : 'h' })
100100
101- def test_text_html (self ):
101+ def test_text_html_simple (self ):
102102 test_html_string = 'Test for <<b>bold</b>, <i>ita_lic</i>, <code>code</code>, <a href="http://github.com/">links</a> and <pre>pre</pre>.'
103103 text_html = self .test_message .text_html
104104 self .assertEquals (test_html_string , text_html )
105105
106- def test_text_markdown (self ):
106+ def test_text_markdown_simple (self ):
107107 test_md_string = 'Test for <*bold*, _ita\_lic_, `code`, [links](http://github.com/) and ```pre```.'
108108 text_markdown = self .test_message .text_markdown
109109 self .assertEquals (test_md_string , text_markdown )
110110
111+ def test_text_html_emoji (self ):
112+ text = (b'\\ U0001f469\\ u200d\\ U0001f469\\ u200d ABC' ).decode ('unicode-escape' )
113+ expected = (b'\\ U0001f469\\ u200d\\ U0001f469\\ u200d <b>ABC</b>' ).decode ('unicode-escape' )
114+ bold_entity = telegram .MessageEntity (type = telegram .MessageEntity .BOLD , offset = 7 , length = 3 )
115+ message = telegram .Message (
116+ message_id = 1 , from_user = None , date = None , chat = None , text = text , entities = [bold_entity ])
117+ self .assertEquals (expected , message .text_html )
118+
119+ def test_text_markdown_emoji (self ):
120+ text = (b'\\ U0001f469\\ u200d\\ U0001f469\\ u200d ABC' ).decode ('unicode-escape' )
121+ expected = (b'\\ U0001f469\\ u200d\\ U0001f469\\ u200d *ABC*' ).decode ('unicode-escape' )
122+ bold_entity = telegram .MessageEntity (type = telegram .MessageEntity .BOLD , offset = 7 , length = 3 )
123+ message = telegram .Message (
124+ message_id = 1 , from_user = None , date = None , chat = None , text = text , entities = [bold_entity ])
125+ self .assertEquals (expected , message .text_markdown )
126+
127+ def test_parse_entities_url_emoji (self ):
128+ url = b'http://github.com/?unicode=\\ u2713\\ U0001f469' .decode ('unicode-escape' )
129+ text = 'some url'
130+ link_entity = telegram .MessageEntity (type = telegram .MessageEntity .URL , offset = 0 , length = 8 , url = url )
131+ message = telegram .Message (
132+ message_id = 1 ,
133+ from_user = None ,
134+ date = None ,
135+ chat = None ,
136+ text = text ,
137+ entities = [link_entity ])
138+ self .assertDictEqual (message .parse_entities (), {link_entity : text })
139+ self .assertEqual (next (iter (message .parse_entities ())).url , url )
140+
111141 @flaky (3 , 1 )
112142 def test_reply_text (self ):
113143 """Test for Message.reply_text"""
0 commit comments