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, mount } from '@vue/test-utils';
|
2020-11-04 11:52:19 +00:00
|
|
|
|
|
|
|
import { newNotificationsModule } from '@/app/store/modules/notifications';
|
|
|
|
import { UINotification } from '@/app/types/notifications';
|
|
|
|
import { NotificationsHttpApi } from '@/storagenode/api/notifications';
|
|
|
|
import { Notification, NotificationTypes } from '@/storagenode/notifications/notifications';
|
|
|
|
import { NotificationsService } from '@/storagenode/notifications/service';
|
2022-11-04 11:48:16 +00:00
|
|
|
|
|
|
|
import SNONotification from '@/app/components/notifications/SNONotification.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('SNONotification', (): void => {
|
|
|
|
it('renders correctly with default props', (): void => {
|
2021-08-23 10:32:02 +01:00
|
|
|
const wrapper = mount(SNONotification, {
|
2020-11-04 11:52:19 +00:00
|
|
|
store,
|
|
|
|
localVue,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders correctly', async (): Promise<void> => {
|
2022-04-06 16:51:04 +01:00
|
|
|
const note = new Notification(
|
2020-11-04 11:52:19 +00:00
|
|
|
'123',
|
|
|
|
'1234',
|
2020-12-18 19:27:28 +00:00
|
|
|
NotificationTypes.AuditCheckFailure,
|
2020-11-04 11:52:19 +00:00
|
|
|
'title1',
|
|
|
|
'message1',
|
|
|
|
);
|
2022-04-06 16:51:04 +01:00
|
|
|
const uinote = new UINotification(note);
|
2020-11-04 11:52:19 +00:00
|
|
|
|
2021-08-23 10:32:02 +01:00
|
|
|
const wrapper = mount(SNONotification, {
|
2020-11-04 11:52:19 +00:00
|
|
|
store,
|
|
|
|
localVue,
|
|
|
|
propsData: {
|
2022-04-06 16:51:04 +01:00
|
|
|
notification: uinote,
|
2020-11-04 11:52:19 +00:00
|
|
|
isSmall: false,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
await wrapper.find('.notification-item').trigger('mouseenter');
|
|
|
|
|
2022-04-06 16:51:04 +01:00
|
|
|
// TODO: verify that the notification has been marked as read
|
|
|
|
// expect(state.notifications[0].isRead).toBe(true);
|
2020-11-04 11:52:19 +00:00
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|