From 25bf28f051f2adc22bdac82b7f1ab5c3fc003a39 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 16 Jun 2021 01:44:29 +0300 Subject: [PATCH] added tests just in case --- .../specs/components/rich_content.spec.js | 104 +++++++++++++++++- 1 file changed, 102 insertions(+), 2 deletions(-) diff --git a/test/unit/specs/components/rich_content.spec.js b/test/unit/specs/components/rich_content.spec.js index be51bbd1..96c480ea 100644 --- a/test/unit/specs/components/rich_content.spec.js +++ b/test/unit/specs/components/rich_content.spec.js @@ -1,4 +1,4 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils' +import { mount, shallowMount, createLocalVue } from '@vue/test-utils' import RichContent from 'src/components/rich_content/rich_content.jsx' const localVue = createLocalVue() @@ -640,7 +640,107 @@ describe('RichContent', () => { expect(wrapper.html()).to.eql(compwrap(expected)) }) - it('contents of a link', () => { + it('rich contents of a mention are handled properly', () => { + const html = [ + p( + 'Testing' + ), + p( + '', + '', + 'https://', + '', + 'lol.tld/', + '', + '', + '' + ) + ].join('') + const expected = [ + p( + 'Testing' + ), + p( + '', + '' + ) + ].join('') + + const wrapper = shallowMount(RichContent, { + localVue, + propsData: { + hideMentions: false, + handleLinks: true, + greentext: true, + emoji: [], + html + } + }) + + expect(wrapper.html()).to.eql(compwrap(expected)) + }) + + it('rich contents of a mention in beginning are handled properly', () => { + const html = [ + p( + '', + '', + 'https://', + '', + 'lol.tld/', + '', + '', + '' + ), + p( + 'Testing' + ) + ].join('') + const expected = [ + p( + '', + '', + '', + '', // v-if placeholder + '' + ), + p( + 'Testing' + ) + ].join('') + + const wrapper = mount(RichContent, { + localVue, + stubs: { + MentionLink: true + }, + propsData: { + hideMentions: false, + handleLinks: true, + greentext: true, + emoji: [], + html + } + }) + + expect(wrapper.html()).to.eql(compwrap(expected)) + }) + + it('rich contents of a link are handled properly', () => { const html = [ '

', 'Freenode is dead.

',