diff --git a/webapp/components/notifications/Notification/NotificationPostCard.vue b/webapp/components/notifications/Notification/NotificationPostCard.vue index 85049b0c3..6197f0bda 100644 --- a/webapp/components/notifications/Notification/NotificationPostCard.vue +++ b/webapp/components/notifications/Notification/NotificationPostCard.vue @@ -20,10 +20,13 @@ /> + +
+ @@ -43,8 +46,10 @@ export default { }, computed: { excerpt() { + const { contentExcerpt } = this.post + if (!contentExcerpt) return '' // remove all links from excerpt to prevent issues with the sorrounding link - let excerpt = this.post.contentExcerpt.replace(/(.+)<\/a>/gim, '$1') + let excerpt = contentExcerpt.replace(/(.+)<\/a>/gim, '$1') // do not display content that is only linebreaks if (excerpt.replace(/
/gim, '').trim() === '') { excerpt = '' diff --git a/webapp/components/notifications/Notification/spec.js b/webapp/components/notifications/Notification/spec.js new file mode 100644 index 000000000..a39cb5940 --- /dev/null +++ b/webapp/components/notifications/Notification/spec.js @@ -0,0 +1,43 @@ +import { config, mount, createLocalVue, RouterLinkStub } from '@vue/test-utils' +import Notification from '.' +import Styleguide from '@human-connection/styleguide' + +const localVue = createLocalVue() + +localVue.use(Styleguide) + +config.stubs['no-ssr'] = '' + +describe('Notification', () => { + let wrapper + let stubs + let propsData + beforeEach(() => { + propsData = {} + stubs = { + NuxtLink: RouterLinkStub + } + }) + + const Wrapper = () => { + return mount(Notification, { + stubs, + propsData, + localVue + }) + } + + describe('given a notification', () => { + beforeEach(() => { + propsData.notification = { + post: { + title: "It's a title" + } + } + }) + + it('renders title', () => { + expect(Wrapper().text()).toContain("It's a title") + }) + }) +})