Ocelot-Social/webapp/components/NotificationList/NotificationList.spec.js
Wolfgang Huß af8b479fb4 Merge branch 'master' of github.com:Human-Connection/Human-Connection into 1709-send-feedbacks-in-report-processes-second-approach-merge-master
# Conflicts:
#	backend/package.json
#	backend/src/db/seed.js
#	backend/src/middleware/notifications/notificationsMiddleware.js
#	backend/src/middleware/notifications/notificationsMiddleware.spec.js
#	backend/src/schema/resolvers/notifications.js
#	backend/src/schema/resolvers/notifications.spec.js
#	backend/yarn.lock
#	cypress/integration/common/steps.js
#	webapp/components/Notification/Notification.spec.js
#	webapp/components/Notification/Notification.vue
#	webapp/components/NotificationList/NotificationList.spec.js
#	webapp/components/UserTeaser/UserTeaser.vue
#	webapp/locales/de.json
#	webapp/locales/en.json
#	webapp/package.json
#	webapp/yarn.lock
2020-03-09 09:34:49 +01:00

86 lines
1.9 KiB
JavaScript

import { config, shallowMount, mount, RouterLinkStub } from '@vue/test-utils'
import NotificationList from './NotificationList'
import Notification from '../Notification/Notification'
import Vuex from 'vuex'
import { testNotifications } from '~/components/utils/Notifications'
const localVue = global.localVue
localVue.filter('truncate', string => string)
config.stubs['client-only'] = '<span><slot /></span>'
config.stubs['v-popover'] = '<span><slot /></span>'
describe('NotificationList.vue', () => {
let wrapper
let mocks
let stubs
let store
let propsData
beforeEach(() => {
store = new Vuex.Store({
getters: {
'auth/isModerator': () => false,
'auth/user': () => {
return {}
},
},
})
mocks = {
$t: jest.fn(),
}
stubs = {
NuxtLink: RouterLinkStub,
}
propsData = { notifications: testNotifications }
})
describe('shallowMount', () => {
const Wrapper = () => {
return shallowMount(NotificationList, {
propsData,
mocks,
store,
localVue,
})
}
beforeEach(() => {
wrapper = Wrapper()
})
it('renders Notification.vue for each notification of the user', () => {
expect(wrapper.findAll(Notification)).toHaveLength(3)
})
})
describe('mount', () => {
const Wrapper = () => {
return mount(NotificationList, {
propsData,
mocks,
stubs,
store,
localVue,
})
}
beforeEach(() => {
wrapper = Wrapper()
})
describe('click on a notification', () => {
beforeEach(() => {
wrapper.find('.notification .notifications-card').trigger('click')
})
it("emits 'markAsRead' with the id of the notification source", () => {
expect(wrapper.emitted('markAsRead')[0]).toEqual(['post-1'])
})
})
})
})