mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Adding missing tests for truncate_html_words() (#2918)
This commit is contained in:
parent
ef7e26329c
commit
b8bf5950b6
1 changed files with 20 additions and 0 deletions
|
|
@ -259,6 +259,26 @@ class TestUtils(LoggedTestCase):
|
|||
utils.truncate_html_words('<!-- comment -->' + 'word ' * 100, 20),
|
||||
'<!-- comment -->' + 'word ' * 20 + '…')
|
||||
|
||||
# Words enclosed or intervaled by HTML tags with a custom end
|
||||
# marker containing HTML tags.
|
||||
self.assertEqual(
|
||||
utils.truncate_html_words('<p>' + 'word ' * 100 + '</p>', 20,
|
||||
'<span>marker</span>'),
|
||||
'<p>' + 'word ' * 20 + '<span>marker</span></p>')
|
||||
self.assertEqual(
|
||||
utils.truncate_html_words(
|
||||
'<span\nstyle="\n…\n">' + 'word ' * 100 + '</span>', 20,
|
||||
'<span>marker</span>'),
|
||||
'<span\nstyle="\n…\n">' + 'word ' * 20 + '<span>marker</span></span>')
|
||||
self.assertEqual(
|
||||
utils.truncate_html_words('<br>' + 'word ' * 100, 20,
|
||||
'<span>marker</span>'),
|
||||
'<br>' + 'word ' * 20 + '<span>marker</span>')
|
||||
self.assertEqual(
|
||||
utils.truncate_html_words('<!-- comment -->' + 'word ' * 100, 20,
|
||||
'<span>marker</span>'),
|
||||
'<!-- comment -->' + 'word ' * 20 + '<span>marker</span>')
|
||||
|
||||
# Words with hypens and apostrophes.
|
||||
self.assertEqual(
|
||||
utils.truncate_html_words("a-b " * 100, 20),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue