2021-05-25 08:30:21 +00:00
|
|
|
import NotificationBell from '../NotificationBell';
|
|
|
|
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
|
|
|
import Vuex from 'vuex';
|
|
|
|
import VueI18n from 'vue-i18n';
|
|
|
|
|
|
|
|
import i18n from 'dashboard/i18n';
|
|
|
|
|
|
|
|
const localVue = createLocalVue();
|
|
|
|
localVue.use(Vuex);
|
|
|
|
localVue.use(VueI18n);
|
|
|
|
|
|
|
|
const i18nConfig = new VueI18n({
|
|
|
|
locale: 'en',
|
|
|
|
messages: i18n,
|
|
|
|
});
|
|
|
|
|
2022-03-25 13:32:45 +00:00
|
|
|
const $route = {
|
|
|
|
name: 'notifications_index',
|
|
|
|
};
|
|
|
|
|
2021-05-25 08:30:21 +00:00
|
|
|
describe('notificationBell', () => {
|
|
|
|
const accountId = 1;
|
|
|
|
const notificationMetadata = { unreadCount: 19 };
|
|
|
|
let store = null;
|
|
|
|
let actions = null;
|
|
|
|
let modules = null;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
actions = {
|
|
|
|
showNotification: jest.fn(),
|
|
|
|
};
|
|
|
|
modules = {
|
|
|
|
auth: {
|
|
|
|
getters: {
|
|
|
|
getCurrentAccountId: () => accountId,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
notifications: {
|
|
|
|
getters: {
|
|
|
|
'notifications/getMeta': () => notificationMetadata,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
store = new Vuex.Store({
|
|
|
|
actions,
|
|
|
|
modules,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('it should return unread count 19 ', () => {
|
2022-03-25 13:32:45 +00:00
|
|
|
const wrapper = shallowMount(NotificationBell, {
|
2021-05-25 08:30:21 +00:00
|
|
|
localVue,
|
|
|
|
i18n: i18nConfig,
|
2022-03-25 13:32:45 +00:00
|
|
|
store,
|
|
|
|
mocks: {
|
|
|
|
$route,
|
|
|
|
},
|
2021-05-25 08:30:21 +00:00
|
|
|
});
|
2022-03-25 13:32:45 +00:00
|
|
|
expect(wrapper.vm.unreadCount).toBe('19');
|
2021-05-25 08:30:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('it should return unread count 99+ ', async () => {
|
2022-03-25 13:32:45 +00:00
|
|
|
notificationMetadata.unreadCount = 100;
|
|
|
|
const wrapper = shallowMount(NotificationBell, {
|
|
|
|
localVue,
|
|
|
|
i18n: i18nConfig,
|
|
|
|
store,
|
|
|
|
mocks: {
|
|
|
|
$route,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
expect(wrapper.vm.unreadCount).toBe('99+');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('isNotificationPanelActive', async () => {
|
2021-05-25 08:30:21 +00:00
|
|
|
const notificationBell = shallowMount(NotificationBell, {
|
|
|
|
store,
|
|
|
|
localVue,
|
|
|
|
i18n: i18nConfig,
|
2022-03-25 13:32:45 +00:00
|
|
|
mocks: {
|
|
|
|
$route,
|
|
|
|
},
|
2021-05-25 08:30:21 +00:00
|
|
|
});
|
2022-03-25 13:32:45 +00:00
|
|
|
|
|
|
|
expect(notificationBell.vm.isNotificationPanelActive).toBe(true);
|
2021-05-25 08:30:21 +00:00
|
|
|
});
|
|
|
|
});
|