mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Implement first test for Notification
Fixed a bug along the way `(post.contentExcerpt == null)`
This commit is contained in:
parent
af60ad39a4
commit
128480fd0e
@ -20,10 +20,13 @@
|
||||
/>
|
||||
</no-ssr>
|
||||
<ds-space margin-bottom="x-small" />
|
||||
<!-- eslint-disable vue/no-v-html -->
|
||||
<!-- TODO: replace editor content with tiptap render view -->
|
||||
<div
|
||||
class="hc-editor-content"
|
||||
v-html="excerpt"
|
||||
/>
|
||||
<!-- eslint-enable vue/no-v-html -->
|
||||
</ds-card>
|
||||
</template>
|
||||
|
||||
@ -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.*>(.+)<\/a>/gim, '$1')
|
||||
let excerpt = contentExcerpt.replace(/<a.*>(.+)<\/a>/gim, '$1')
|
||||
// do not display content that is only linebreaks
|
||||
if (excerpt.replace(/<br>/gim, '').trim() === '') {
|
||||
excerpt = ''
|
||||
|
||||
43
webapp/components/notifications/Notification/spec.js
Normal file
43
webapp/components/notifications/Notification/spec.js
Normal file
@ -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'] = '<span><slot /></span>'
|
||||
|
||||
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")
|
||||
})
|
||||
})
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user