diff --git a/webapp/components/notifications/NotificationList.spec.js b/webapp/components/notifications/NotificationList.spec.js index 94da7869d..d98a7ea31 100644 --- a/webapp/components/notifications/NotificationList.spec.js +++ b/webapp/components/notifications/NotificationList.spec.js @@ -26,7 +26,6 @@ describe('NotificationList.vue', () => { let Wrapper let mocks let stubs - let user let store let propsData diff --git a/webapp/components/notifications/NotificationMenu.spec.js b/webapp/components/notifications/NotificationMenu.spec.js new file mode 100644 index 000000000..62b631073 --- /dev/null +++ b/webapp/components/notifications/NotificationMenu.spec.js @@ -0,0 +1,76 @@ +import { config, shallowMount, createLocalVue } from '@vue/test-utils' +import NotificationMenu from './NotificationMenu.vue' + +import Styleguide from '@human-connection/styleguide' + +const localVue = createLocalVue() + +localVue.use(Styleguide) +localVue.filter('truncate', string => string) + +config.stubs['dropdown'] = '' + +describe('NotificationMenu.vue', () => { + let wrapper + let Wrapper + let mocks + let data + + beforeEach(() => { + mocks = { + $t: jest.fn() + } + data = () => { + return { + notifications: [ + { + id: 'notification-41', + read: false, + post: { + id: 'post-1', + title: 'some post title', + contentExcerpt: 'this is a post content', + author: { + id: 'john-1', + slug: 'john-doe', + name: 'John Doe' + } + } + }, + { + id: 'notification-42', + read: false, + post: { + id: 'post-2', + title: 'another post title', + contentExcerpt: 'this is yet another post content', + author: { + id: 'john-1', + slug: 'john-doe', + name: 'John Doe' + } + } + } + ] + } + } + }) + + describe('shallowMount', () => { + const Wrapper = () => { + return shallowMount(NotificationMenu, { + data, + mocks, + localVue + }) + } + + beforeEach(() => { + wrapper = Wrapper() + }) + + it('displays the total number of notifications', () => { + expect(wrapper.find('ds-button-stub').text()).toEqual('2') + }) + }) +}) diff --git a/webapp/components/notifications/NotificationMenu.vue b/webapp/components/notifications/NotificationMenu.vue index 9bbd1e98d..a950a62be 100644 --- a/webapp/components/notifications/NotificationMenu.vue +++ b/webapp/components/notifications/NotificationMenu.vue @@ -9,7 +9,7 @@ icon="bell" @click.prevent="toggleMenu" > - 1 + {{ totalNotifications }}