Add tests in Notification.spec.js

This commit is contained in:
Wolfgang Huß 2020-01-20 10:29:46 +01:00
parent 23626fdaf5
commit 48403471d5
2 changed files with 68 additions and 1 deletions

View File

@ -167,6 +167,7 @@ describe('Notification', () => {
'notifications.reason.mentioned_in_comment',
)
})
it('renders title', () => {
wrapper = Wrapper()
expect(wrapper.text()).toContain("It's a post title")
@ -198,4 +199,71 @@ describe('Notification', () => {
})
})
})
describe('given a notification about the user has filed a report', () => {
beforeEach(() => {
propsData.notification = {
reason: 'filed_report_on_resource',
from: {
__typename: 'Report',
id: 'reportOnUser',
filed: [
{
reasonCategory: 'discrimination_etc',
reasonDescription: 'This user is harassing me with bigoted remarks!',
reportedResource: {
__typename: 'User',
id: 'badWomen',
slug: 'mrs.-badwomen',
name: 'Mrs. Badwomen',
},
},
],
},
}
})
it('renders reason', () => {
wrapper = Wrapper()
expect(wrapper.find('.reason-text-for-test').text()).toEqual(
'notifications.reason.filed_report_on_resource.user',
)
})
it('renders title', () => {
wrapper = Wrapper()
expect(wrapper.text()).toContain('Mrs. Badwomen')
})
it('renders the identifier "notifications.filedReport.category"', () => {
wrapper = Wrapper()
expect(wrapper.text()).toContain('notifications.filedReport.category')
})
it('renders the identifier "notifications.filedReport.description"', () => {
wrapper = Wrapper()
expect(wrapper.text()).toContain('notifications.filedReport.description')
})
it('renders the users slug', () => {
wrapper = Wrapper()
expect(wrapper.text()).toContain('@mrs.-badwomen')
})
it('has no class "read"', () => {
wrapper = Wrapper()
expect(wrapper.classes()).not.toContain('read')
})
describe('that is read', () => {
beforeEach(() => {
propsData.notification.read = true
wrapper = Wrapper()
})
it('has class "read"', () => {
expect(wrapper.classes()).toContain('read')
})
})
})
})

View File

@ -25,7 +25,6 @@ export default {
},
methods: {
markAsRead(notificationSourceId) {
// Wolle console.log('markAsRead !!! notificationSourceId: ', notificationSourceId)
this.$emit('markAsRead', notificationSourceId)
},
},