2020-11-04 11:52:19 +00:00
|
|
|
// Copyright (C) 2020 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
import Vuex from 'vuex';
|
2022-11-04 11:48:16 +00:00
|
|
|
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
2020-11-04 11:52:19 +00:00
|
|
|
|
|
|
|
import {
|
|
|
|
newNotificationsModule,
|
|
|
|
NOTIFICATIONS_MUTATIONS,
|
|
|
|
} from '@/app/store/modules/notifications';
|
|
|
|
import { NotificationsState, UINotification } from '@/app/types/notifications';
|
|
|
|
import { NotificationsHttpApi } from '@/storagenode/api/notifications';
|
|
|
|
import { Notification } from '@/storagenode/notifications/notifications';
|
|
|
|
import { NotificationsService } from '@/storagenode/notifications/service';
|
2022-11-04 11:48:16 +00:00
|
|
|
|
|
|
|
import NotificationsPopup from '@/app/components/notifications/NotificationsPopup.vue';
|
2020-11-04 11:52:19 +00:00
|
|
|
|
|
|
|
const localVue = createLocalVue();
|
|
|
|
localVue.use(Vuex);
|
|
|
|
|
|
|
|
const notificationsApi = new NotificationsHttpApi();
|
|
|
|
const notificationsService = new NotificationsService(notificationsApi);
|
|
|
|
const notificationsModule = newNotificationsModule(notificationsService);
|
|
|
|
|
2022-11-04 11:48:16 +00:00
|
|
|
const store = new Vuex.Store({ modules: { notificationsModule } });
|
2020-11-04 11:52:19 +00:00
|
|
|
|
|
|
|
describe('NotificationsPopup', (): void => {
|
|
|
|
it('renders correctly with no notifications', (): void => {
|
|
|
|
const wrapper = shallowMount(NotificationsPopup, {
|
|
|
|
store,
|
|
|
|
localVue,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders correctly with less than 4 notifications', async (): Promise<void> => {
|
|
|
|
await store.commit(NOTIFICATIONS_MUTATIONS.SET_LATEST, new NotificationsState(
|
|
|
|
[new UINotification(new Notification())],
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
));
|
|
|
|
|
|
|
|
const wrapper = shallowMount(NotificationsPopup, {
|
|
|
|
store,
|
|
|
|
localVue,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders correctly with more than 4 notifications', async (): Promise<void> => {
|
|
|
|
await store.commit(NOTIFICATIONS_MUTATIONS.SET_LATEST, new NotificationsState(
|
|
|
|
[
|
|
|
|
new UINotification(new Notification('1')),
|
|
|
|
new UINotification(new Notification('2')),
|
|
|
|
new UINotification(new Notification('3')),
|
|
|
|
new UINotification(new Notification('4')),
|
|
|
|
new UINotification(new Notification('5')),
|
|
|
|
],
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
));
|
|
|
|
|
|
|
|
const wrapper = shallowMount(NotificationsPopup, {
|
|
|
|
store,
|
|
|
|
localVue,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|