storj/web/satellite/tests/unit/apiKeys/ApiKeysCopyPopup.spec.ts

51 lines
1.6 KiB
TypeScript
Raw Normal View History

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
import Vuex from 'vuex';
2019-09-09 11:33:39 +01:00
import ApiKeysCopyPopup from '@/components/apiKeys/ApiKeysCopyPopup.vue';
2019-09-09 11:33:39 +01:00
import { ApiKeysApiGql } from '@/api/apiKeys';
import { makeApiKeysModule } from '@/store/modules/apiKeys';
import { makeNotificationsModule } from '@/store/modules/notifications';
import { NotificatorPlugin } from '@/utils/plugins/notificator';
2019-09-09 11:33:39 +01:00
import { createLocalVue, mount } from '@vue/test-utils';
const localVue = createLocalVue();
localVue.use(Vuex);
const notificationPlugin = new NotificatorPlugin();
localVue.use(notificationPlugin);
const apiKeysApi = new ApiKeysApiGql();
const apiKeysModule = makeApiKeysModule(apiKeysApi);
const notificationsModule = makeNotificationsModule();
const testKey = 'test';
const store = new Vuex.Store({ modules: { notificationsModule, apiKeysModule }});
describe('ApiKeysCopyPopup', () => {
it('renders correctly', () => {
const wrapper = mount(ApiKeysCopyPopup, {
store,
localVue,
propsData: {
isPopupShown: true,
apiKeySecret: testKey,
},
});
expect(wrapper).toMatchSnapshot();
expect(wrapper.find('.save-api-popup__copy-area__key-area__key').text()).toBe(testKey);
});
it('function onCloseClick works correctly', async () => {
const wrapper = mount(ApiKeysCopyPopup, {
store,
localVue,
});
await wrapper.vm.onCloseClick();
expect(wrapper.emitted()).toEqual({'closePopup': [[]]});
});
});