fix tests

This commit is contained in:
FloatingGhost 2022-06-15 17:53:52 +01:00
parent 079035670a
commit 93bca5f851
2 changed files with 2 additions and 22 deletions

View file

@ -112,23 +112,6 @@ export default {
} }
} }
const renderLink = (attrs, children) => {
const updatedLink = attrs['href'].replace(/&/g, '&')
const updatedChildren = children.map(child => {
if (typeof child === 'string') {
return child.replace(attrs['href'], updatedLink)
}
if (child[0] === '<span>') {
return <span>
{ child[1] }
</span>
}
return child[1]
})
return <a {...{ attrs }} href={updatedLink}>
{ ...updatedChildren }
</a>
}
// Processor to use with html_tree_converter // Processor to use with html_tree_converter
const processItem = (item, index, array, what) => { const processItem = (item, index, array, what) => {
// Handle text nodes - just add emoji // Handle text nodes - just add emoji
@ -193,9 +176,6 @@ export default {
return renderMention(attrs, children) return renderMention(attrs, children)
} else { } else {
currentMentions = null currentMentions = null
if (attrs['href']) {
return renderLink(attrs, children)
}
break break
} }
case 'span': case 'span':

View file

@ -44,12 +44,12 @@ describe('RichContent', () => {
const html = [ const html = [
p('Testing &#39;em all'), p('Testing &#39;em all'),
'Testing &#39;em all', 'Testing &#39;em all',
'<a href="http://example.com?a=1&amp;b=2">http://example.com?a=1&b=2</a>' '<a href="http://example.com?a=1">http://example.com?a=1</a>'
].join('') ].join('')
const expected = [ const expected = [
p('Testing \'em all'), p('Testing \'em all'),
'Testing \'em all', 'Testing \'em all',
'<a href="http://example.com?a=1&b=2">http://example.com?a=1&b=2</a>' '<a href="http://example.com?a=1" target="_blank">http://example.com?a=1</a>'
].join('') ].join('')
const wrapper = shallowMount(RichContent, { const wrapper = shallowMount(RichContent, {
global, global,