storj/web/storagenode/tests/unit/components/notifications/SNONotification.spec.ts
Egon Elbre e10eabe30b web/storagenode: update dependencies
Also pin all web/multinode dependencies, which was missing from
the other change.

Change-Id: Id78749076af6d80e59949efd73c1e10f5b52589c
2022-04-07 07:50:22 +00:00

60 lines
1.9 KiB
TypeScript

// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
import Vuex from 'vuex';
import SNONotification from '@/app/components/notifications/SNONotification.vue';
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';
import { createLocalVue, mount } from '@vue/test-utils';
const localVue = createLocalVue();
localVue.use(Vuex);
const notificationsApi = new NotificationsHttpApi();
const notificationsService = new NotificationsService(notificationsApi);
const notificationsModule = newNotificationsModule(notificationsService);
const store = new Vuex.Store({ modules: { notificationsModule }});
describe('SNONotification', (): void => {
it('renders correctly with default props', (): void => {
const wrapper = mount(SNONotification, {
store,
localVue,
});
expect(wrapper).toMatchSnapshot();
});
it('renders correctly', async (): Promise<void> => {
const note = new Notification(
'123',
'1234',
NotificationTypes.AuditCheckFailure,
'title1',
'message1',
);
const uinote = new UINotification(note);
const wrapper = mount(SNONotification, {
store,
localVue,
propsData: {
notification: uinote,
isSmall: false,
},
});
await wrapper.find('.notification-item').trigger('mouseenter');
// TODO: verify that the notification has been marked as read
// expect(state.notifications[0].isRead).toBe(true);
expect(wrapper).toMatchSnapshot();
});
});