diff --git a/webapp/components/Editor/Editor.spec.js b/webapp/components/Editor/Editor.spec.js index 866b96aba..83c8ab26e 100644 --- a/webapp/components/Editor/Editor.spec.js +++ b/webapp/components/Editor/Editor.spec.js @@ -16,6 +16,22 @@ describe('Editor.vue', () => { let mocks let getters + const Wrapper = () => { + const store = new Vuex.Store({ + getters, + }) + return (wrapper = mount(Editor, { + mocks, + propsData, + localVue, + sync: false, + stubs: { + transition: false, + }, + store, + })) + } + beforeEach(() => { propsData = {} mocks = { @@ -26,25 +42,10 @@ describe('Editor.vue', () => { return 'some cool placeholder' }, } + wrapper = Wrapper() }) describe('mount', () => { - let Wrapper = () => { - const store = new Vuex.Store({ - getters, - }) - return (wrapper = mount(Editor, { - mocks, - propsData, - localVue, - sync: false, - stubs: { - transition: false, - }, - store, - })) - } - it('renders', () => { expect(Wrapper().is('div')).toBe(true) }) @@ -67,5 +68,31 @@ describe('Editor.vue', () => { ) }) }) + + describe('optional extensions', () => { + it('sets the Mention items to the users', () => { + propsData.users = [{ id: 'u345' }] + wrapper = Wrapper() + expect(wrapper.vm.editor.extensions.options.mention.items()).toEqual(propsData.users) + }) + + it('mentions is not an option when there are no users', () => { + expect(wrapper.vm.editor.extensions.options).toEqual( + expect.not.objectContaining({ mention: expect.anything() }), + ) + }) + + it('sets the Hashtag items to the hashtags', () => { + propsData.hashtags = [{ id: 'Frieden' }] + wrapper = Wrapper() + expect(wrapper.vm.editor.extensions.options.hashtag.items()).toEqual(propsData.hashtags) + }) + + it('hashtags is not an option when there are no hashtags', () => { + expect(wrapper.vm.editor.extensions.options).toEqual( + expect.not.objectContaining({ hashtag: expect.anything() }), + ) + }) + }) }) }) diff --git a/webapp/components/Editor/Editor.vue b/webapp/components/Editor/Editor.vue index c2a4dac93..cefd89de4 100644 --- a/webapp/components/Editor/Editor.vue +++ b/webapp/components/Editor/Editor.vue @@ -212,7 +212,7 @@ export default { data() { // Set array of optional extensions by analysing the props. let optionalExtensions = [] - if (this.users) { + if (this.users && this.users.length) { optionalExtensions.push( new Mention({ // a list of all suggested items @@ -287,7 +287,7 @@ export default { }), ) } - if (this.hashtags) { + if (this.hashtags && this.hashtags.length) { optionalExtensions.push( new Hashtag({ // a list of all suggested items diff --git a/webapp/components/notifications/Notification/spec.js b/webapp/components/notifications/Notification/Notification.spec.js similarity index 89% rename from webapp/components/notifications/Notification/spec.js rename to webapp/components/notifications/Notification/Notification.spec.js index ae14301f0..8fbc524fb 100644 --- a/webapp/components/notifications/Notification/spec.js +++ b/webapp/components/notifications/Notification/Notification.spec.js @@ -1,5 +1,5 @@ import { config, mount, createLocalVue, RouterLinkStub } from '@vue/test-utils' -import Notification from '.' +import Notification from './Notification' import Styleguide from '@human-connection/styleguide' import Filters from '~/plugins/vue-filters' @@ -49,6 +49,10 @@ describe('Notification', () => { expect(Wrapper().text()).toContain("It's a title") }) + it('renders the contentExcerpt', () => { + expect(Wrapper().text()).toContain('@jenny-rostock is the best') + }) + it('has no class "read"', () => { expect(Wrapper().classes()).not.toContain('read') }) diff --git a/webapp/components/notifications/Notification/index.vue b/webapp/components/notifications/Notification/Notification.vue similarity index 95% rename from webapp/components/notifications/Notification/index.vue rename to webapp/components/notifications/Notification/Notification.vue index ef0e51817..ae1eeddc9 100644 --- a/webapp/components/notifications/Notification/index.vue +++ b/webapp/components/notifications/Notification/Notification.vue @@ -69,7 +69,6 @@ export default { } }, hashParam() { - // Wolle: console.log('this.post.id: ', this.post.id, 'this.comment.id: ', this.comment.id) return this.post.id ? {} : { hash: `#commentId-${this.comment.id}` } }, }, diff --git a/webapp/components/notifications/NotificationList/spec.js b/webapp/components/notifications/NotificationList/NotificationList.spec.js similarity index 96% rename from webapp/components/notifications/NotificationList/spec.js rename to webapp/components/notifications/NotificationList/NotificationList.spec.js index 04b4fbb95..a7a121ea9 100644 --- a/webapp/components/notifications/NotificationList/spec.js +++ b/webapp/components/notifications/NotificationList/NotificationList.spec.js @@ -1,6 +1,6 @@ import { config, shallowMount, mount, createLocalVue, RouterLinkStub } from '@vue/test-utils' -import NotificationList from '.' -import Notification from '../Notification' +import NotificationList from './NotificationList' +import Notification from '../Notification/Notification' import Vuex from 'vuex' import Filters from '~/plugins/vue-filters' diff --git a/webapp/components/notifications/NotificationList/index.vue b/webapp/components/notifications/NotificationList/NotificationList.vue similarity index 90% rename from webapp/components/notifications/NotificationList/index.vue rename to webapp/components/notifications/NotificationList/NotificationList.vue index af1c86732..43783ea56 100644 --- a/webapp/components/notifications/NotificationList/index.vue +++ b/webapp/components/notifications/NotificationList/NotificationList.vue @@ -10,7 +10,7 @@