From 636dbdaba8375cb991368620419e2997df0f57a9 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 13 Jun 2021 22:22:59 +0300 Subject: more fixes --- test/unit/specs/components/rich_content.spec.js | 99 +++++++++++++++++++++++++ 1 file changed, 99 insertions(+) (limited to 'test') diff --git a/test/unit/specs/components/rich_content.spec.js b/test/unit/specs/components/rich_content.spec.js index ff491a3a..835fbea2 100644 --- a/test/unit/specs/components/rich_content.spec.js +++ b/test/unit/specs/components/rich_content.spec.js @@ -416,4 +416,103 @@ describe('RichContent', () => { expect(wrapper.html()).to.eql(compwrap(expected)) }) + + it('Don\'t remove last mention if it\'s the only one', () => { + const html = [ + 'Bruh', + 'Bruh', + makeMention('foo'), + makeMention('bar'), + makeMention('baz') + ].join('
') + + const wrapper = shallowMount(RichContent, { + localVue, + propsData: { + handleLinks: true, + greentext: true, + emoji: [], + html + } + }) + + expect(wrapper.html()).to.eql(compwrap(html)) + }) + + it('Don\'t remove last mentions if there are more than one first mention - remove first instead', () => { + const html = [ + [ + makeMention('foo'), + makeMention('bar') + ].join(' '), + 'Bruh', + 'Bruh', + [ + makeMention('foo'), + makeMention('bar'), + makeMention('baz') + ].join(' ') + ].join('\n') + + const expected = [ + [ + removedMentionSpan, + removedMentionSpan, + 'Bruh' // Due to trim we remove extra newline + ].join(''), + 'Bruh', + lastMentions([ + stubMention('foo'), + stubMention('bar'), + stubMention('baz') + ].join(' ')) + ].join('\n') + + const wrapper = shallowMount(RichContent, { + localVue, + propsData: { + handleLinks: true, + greentext: true, + emoji: [], + html + } + }) + + expect(wrapper.html()).to.eql(compwrap(expected)) + }) + + it('Remove last mentions if there\'s just one first mention - remove all', () => { + const html = [ + [ + makeMention('foo') + ].join(' '), + 'Bruh', + 'Bruh', + [ + makeMention('foo'), + makeMention('bar'), + makeMention('baz') + ].join(' ') + ].join('\n') + + const expected = [ + [ + removedMentionSpan, + 'Bruh' // Due to trim we remove extra newline + ].join(''), + 'Bruh\n' // Can't remove this one yet + ].join('\n') + + const wrapper = shallowMount(RichContent, { + localVue, + propsData: { + handleLinks: true, + greentext: true, + emoji: [], + html + } + }) + + expect(wrapper.html()).to.eql(compwrap(expected)) + }) }) -- cgit v1.2.3-70-g09d2