Skip to content
Snippets Groups Projects
Commit be79643b authored by HJ's avatar HJ :fire:
Browse files

fix emoji processor not leaving string as-is if no emoji are found

parent 35dedf84
No related branches found
No related tags found
2 merge requests!1421Update MASTER for 2.4.2,!1392Status HTML parsing - better emoji and mentions rendering
...@@ -118,6 +118,7 @@ export const processTextForEmoji = (text, emojis, processor) => { ...@@ -118,6 +118,7 @@ export const processTextForEmoji = (text, emojis, processor) => {
textBuffer += char textBuffer += char
} }
} }
if (textBuffer) buffer.push(textBuffer)
return buffer return buffer
} }
......
...@@ -57,7 +57,7 @@ describe('MiniHtmlConverter', () => { ...@@ -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>' 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([ expect(convertHtml(inputOutput)).to.eql([
[ [
...@@ -110,6 +110,24 @@ describe('MiniHtmlConverter', () => { ...@@ -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', () => { describe('processTextForEmoji', () => {
it('processes all emoji in text', () => { it('processes all emoji in text', () => {
...@@ -126,5 +144,14 @@ describe('MiniHtmlConverter', () => { ...@@ -126,5 +144,14 @@ describe('MiniHtmlConverter', () => {
{ shortcode: 'lmao', src: 'LMAO' } { 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'
])
})
})
}) })
}) })
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment