2019-08-15 19:21:46 +01:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2020-02-06 11:46:59 +00:00
|
|
|
import VueClipboard from 'vue-clipboard2';
|
2019-08-15 19:21:46 +01:00
|
|
|
import Vuex from 'vuex';
|
2019-09-09 11:33:39 +01:00
|
|
|
|
2019-08-15 19:21:46 +01:00
|
|
|
import ApiKeysCopyPopup from '@/components/apiKeys/ApiKeysCopyPopup.vue';
|
2019-09-09 11:33:39 +01:00
|
|
|
|
|
|
|
import { ApiKeysApiGql } from '@/api/apiKeys';
|
2019-08-15 19:21:46 +01:00
|
|
|
import { makeApiKeysModule } from '@/store/modules/apiKeys';
|
2019-08-29 11:05:22 +01:00
|
|
|
import { makeNotificationsModule } from '@/store/modules/notifications';
|
2019-10-28 17:33:06 +00:00
|
|
|
import { NotificatorPlugin } from '@/utils/plugins/notificator';
|
2019-09-09 11:33:39 +01:00
|
|
|
import { createLocalVue, mount } from '@vue/test-utils';
|
2019-08-15 19:21:46 +01:00
|
|
|
|
|
|
|
const localVue = createLocalVue();
|
|
|
|
localVue.use(Vuex);
|
2020-02-06 11:46:59 +00:00
|
|
|
localVue.use(VueClipboard);
|
2019-10-28 17:33:06 +00:00
|
|
|
const notificationPlugin = new NotificatorPlugin();
|
|
|
|
localVue.use(notificationPlugin);
|
2019-08-19 11:00:38 +01:00
|
|
|
const apiKeysApi = new ApiKeysApiGql();
|
|
|
|
const apiKeysModule = makeApiKeysModule(apiKeysApi);
|
2019-08-29 11:05:22 +01:00
|
|
|
const notificationsModule = makeNotificationsModule();
|
2020-01-23 13:06:58 +00:00
|
|
|
const testKey = 'test';
|
2019-08-29 11:05:22 +01:00
|
|
|
|
|
|
|
const store = new Vuex.Store({ modules: { notificationsModule, apiKeysModule }});
|
2019-08-15 19:21:46 +01:00
|
|
|
|
2020-06-02 17:38:44 +01:00
|
|
|
describe('ApiKeysCopyPopup', (): void => {
|
2020-04-02 12:28:25 +01:00
|
|
|
it('renders correctly', async (): Promise<void> => {
|
2019-08-15 19:21:46 +01:00
|
|
|
const wrapper = mount(ApiKeysCopyPopup, {
|
|
|
|
store,
|
2019-09-13 15:58:18 +01:00
|
|
|
localVue,
|
2020-01-23 13:06:58 +00:00
|
|
|
propsData: {
|
|
|
|
isPopupShown: true,
|
|
|
|
apiKeySecret: testKey,
|
|
|
|
},
|
2019-08-15 19:21:46 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
2020-04-02 12:28:25 +01:00
|
|
|
await expect(wrapper.find('.save-api-popup__copy-area__key-area__key').text()).toBe(testKey);
|
2019-08-15 19:21:46 +01:00
|
|
|
});
|
|
|
|
|
2020-04-02 12:28:25 +01:00
|
|
|
it('function onCloseClick works correctly', async (): Promise<void> => {
|
2019-08-15 19:21:46 +01:00
|
|
|
const wrapper = mount(ApiKeysCopyPopup, {
|
|
|
|
store,
|
|
|
|
localVue,
|
|
|
|
});
|
|
|
|
|
2020-01-08 15:58:28 +00:00
|
|
|
await wrapper.vm.onCloseClick();
|
2019-08-15 19:21:46 +01:00
|
|
|
|
|
|
|
expect(wrapper.emitted()).toEqual({'closePopup': [[]]});
|
|
|
|
});
|
|
|
|
});
|