aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2021-06-07 12:38:27 +0300
committerHenry Jameson <me@hjkos.com>2021-06-07 18:41:47 +0300
commitbe79643bcf6f05df500f0d6bcb773f07dd15da3d (patch)
tree8c2430ab1ab64c07165a32fd172350bdc18df3cf /test
parent35dedf8416b423abb867b052d37f14becd0de34a (diff)
fix emoji processor not leaving string as-is if no emoji are found
Diffstat (limited to 'test')
-rw-r--r--test/unit/specs/services/tiny_post_html_processor/mini_post_html_processor.spec.js29
1 files changed, 28 insertions, 1 deletions
diff --git a/test/unit/specs/services/tiny_post_html_processor/mini_post_html_processor.spec.js b/test/unit/specs/services/tiny_post_html_processor/mini_post_html_processor.spec.js
index 41818f57..c4e3f688 100644
--- a/test/unit/specs/services/tiny_post_html_processor/mini_post_html_processor.spec.js
+++ b/test/unit/specs/services/tiny_post_html_processor/mini_post_html_processor.spec.js
@@ -57,7 +57,7 @@ describe('MiniHtmlConverter', () => {
]
])
})
- it('realistic case', () => {
+ it('realistic case 1', () => {
const inputOutput = '<p><span class="h-card"><a class="u-url mention" data-user="9wRC6T2ZZiKWJ0vUi8" href="https://cawfee.club/users/benis" rel="ugc">@<span>benis</span></a></span> <span class="h-card"><a class="u-url mention" data-user="194" href="https://shigusegubu.club/users/hj" rel="ugc">@<span>hj</span></a></span> nice</p>'
expect(convertHtml(inputOutput)).to.eql([
[
@@ -110,6 +110,24 @@ describe('MiniHtmlConverter', () => {
]
])
})
+ it('realistic case 2', () => {
+ const inputOutput = 'Country improv: give me a city<br/>Audience: Memphis<br/>Improv troupe: come on, a better one<br/>Audience: el paso'
+ expect(convertHtml(inputOutput)).to.eql([
+ 'Country improv: give me a city',
+ [
+ '<br/>'
+ ],
+ 'Audience: Memphis',
+ [
+ '<br/>'
+ ],
+ 'Improv troupe: come on, a better one',
+ [
+ '<br/>'
+ ],
+ 'Audience: el paso'
+ ])
+ })
})
describe('processTextForEmoji', () => {
it('processes all emoji in text', () => {
@@ -126,5 +144,14 @@ describe('MiniHtmlConverter', () => {
{ shortcode: 'lmao', src: 'LMAO' }
])
})
+ it('leaves text as is', () => {
+ const inputOutput = 'Number one: that\'s terror'
+ const emojis = []
+ const processor = ({ shortcode, src }) => ({ shortcode, src })
+ expect(processTextForEmoji(inputOutput, emojis, processor)).to.eql([
+ 'Number one: that\'s terror'
+ ])
+ })
+ })
})
})