Commit de531b4f authored by Illya Klymov's avatar Illya Klymov Committed by Vitaly Slobodin

Fix deprecated methods in vue_shared tests

parent 4e0d6868
...@@ -7,10 +7,11 @@ import state from './state'; ...@@ -7,10 +7,11 @@ import state from './state';
Vue.use(Vuex); Vue.use(Vuex);
export default () => export const getStoreConfig = () => ({
new Vuex.Store({ actions,
actions, mutations,
mutations, getters,
getters, state: state(),
state: state(), });
});
export default () => new Vuex.Store(getStoreConfig());
...@@ -2,7 +2,7 @@ import { mount, createLocalVue } from '@vue/test-utils'; ...@@ -2,7 +2,7 @@ import { mount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex'; import Vuex from 'vuex';
import GroupedMetricsReportsApp from 'ee/vue_shared/metrics_reports/grouped_metrics_reports_app.vue'; import GroupedMetricsReportsApp from 'ee/vue_shared/metrics_reports/grouped_metrics_reports_app.vue';
import MetricsReportsIssueBody from 'ee/vue_shared/metrics_reports/components/metrics_reports_issue_body.vue'; import MetricsReportsIssueBody from 'ee/vue_shared/metrics_reports/components/metrics_reports_issue_body.vue';
import store from 'ee/vue_shared/metrics_reports/store'; import { getStoreConfig } from 'ee/vue_shared/metrics_reports/store';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
...@@ -25,7 +25,7 @@ describe('Grouped metrics reports app', () => { ...@@ -25,7 +25,7 @@ describe('Grouped metrics reports app', () => {
}; };
beforeEach(() => { beforeEach(() => {
mockStore = store(); mockStore = new Vuex.Store(getStoreConfig());
mountComponent(); mountComponent();
}); });
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlModal } from '@gitlab/ui';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import ConfirmModal from '~/vue_shared/components/confirm_modal.vue'; import ConfirmModal from '~/vue_shared/components/confirm_modal.vue';
...@@ -21,9 +20,14 @@ describe('vue_shared/components/confirm_modal', () => { ...@@ -21,9 +20,14 @@ describe('vue_shared/components/confirm_modal', () => {
selector: '.test-button', selector: '.test-button',
}; };
const actionSpies = { const popupMethods = {
openModal: jest.fn(), hide: jest.fn(),
closeModal: jest.fn(), show: jest.fn(),
};
const GlModalStub = {
template: '<div><slot></slot></div>',
methods: popupMethods,
}; };
let wrapper; let wrapper;
...@@ -34,8 +38,8 @@ describe('vue_shared/components/confirm_modal', () => { ...@@ -34,8 +38,8 @@ describe('vue_shared/components/confirm_modal', () => {
...defaultProps, ...defaultProps,
...props, ...props,
}, },
methods: { stubs: {
...actionSpies, GlModal: GlModalStub,
}, },
}); });
}; };
...@@ -44,7 +48,7 @@ describe('vue_shared/components/confirm_modal', () => { ...@@ -44,7 +48,7 @@ describe('vue_shared/components/confirm_modal', () => {
wrapper.destroy(); wrapper.destroy();
}); });
const findModal = () => wrapper.find(GlModal); const findModal = () => wrapper.find(GlModalStub);
const findForm = () => wrapper.find('form'); const findForm = () => wrapper.find('form');
const findFormData = () => const findFormData = () =>
findForm() findForm()
...@@ -103,7 +107,7 @@ describe('vue_shared/components/confirm_modal', () => { ...@@ -103,7 +107,7 @@ describe('vue_shared/components/confirm_modal', () => {
}); });
it('does not close modal', () => { it('does not close modal', () => {
expect(actionSpies.closeModal).not.toHaveBeenCalled(); expect(popupMethods.hide).not.toHaveBeenCalled();
}); });
describe('when modal closed', () => { describe('when modal closed', () => {
...@@ -112,7 +116,7 @@ describe('vue_shared/components/confirm_modal', () => { ...@@ -112,7 +116,7 @@ describe('vue_shared/components/confirm_modal', () => {
}); });
it('closes modal', () => { it('closes modal', () => {
expect(actionSpies.closeModal).toHaveBeenCalled(); expect(popupMethods.hide).toHaveBeenCalled();
}); });
}); });
}); });
......
...@@ -14,19 +14,13 @@ import { ...@@ -14,19 +14,13 @@ import {
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
function createRenamedComponent({ function createRenamedComponent({ props = {}, store = new Vuex.Store({}), deep = false }) {
props = {},
methods = {},
store = new Vuex.Store({}),
deep = false,
}) {
const mnt = deep ? mount : shallowMount; const mnt = deep ? mount : shallowMount;
return mnt(Renamed, { return mnt(Renamed, {
propsData: { ...props }, propsData: { ...props },
localVue, localVue,
store, store,
methods,
}); });
} }
...@@ -258,25 +252,17 @@ describe('Renamed Diff Viewer', () => { ...@@ -258,25 +252,17 @@ describe('Renamed Diff Viewer', () => {
'includes a link to the full file for alternate viewer type "$altType"', 'includes a link to the full file for alternate viewer type "$altType"',
({ altType, linkText }) => { ({ altType, linkText }) => {
const file = { ...diffFile }; const file = { ...diffFile };
const clickMock = jest.fn().mockImplementation(() => {});
file.alternate_viewer.name = altType; file.alternate_viewer.name = altType;
wrapper = createRenamedComponent({ wrapper = createRenamedComponent({
deep: true, deep: true,
props: { diffFile: file }, props: { diffFile: file },
methods: {
clickLink: clickMock,
},
}); });
const link = wrapper.find('a'); const link = wrapper.find('a');
expect(link.text()).toEqual(linkText); expect(link.text()).toEqual(linkText);
expect(link.attributes('href')).toEqual(DIFF_FILE_VIEW_PATH); expect(link.attributes('href')).toEqual(DIFF_FILE_VIEW_PATH);
link.vm.$emit('click');
expect(clickMock).toHaveBeenCalled();
}, },
); );
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment