Commit e9da4323 authored by Illya Klymov's avatar Illya Klymov

Fix deprecated `methods` in various `ee` specs

Replace stubbing methods with store mocks
parent 4ab9b3ea
import Vue from 'vue';
import Vuex from 'vuex';
import { shallowMount } from '@vue/test-utils';
import SidebarStatus from 'ee/sidebar/components/status/sidebar_status.vue';
import Status from 'ee/sidebar/components/status/status.vue';
Vue.use(Vuex);
describe('SidebarStatus', () => {
let mediator;
let wrapper;
let handleDropdownClickMock;
const createMediator = states => {
mediator = {
updateStatus: jest.fn().mockResolvedValue(),
store: {
isFetching: {
status: true,
......@@ -19,22 +23,21 @@ describe('SidebarStatus', () => {
};
};
const createWrapper = (mockStore = {}) => {
const createWrapper = ({ noteableState } = {}) => {
const store = new Vuex.Store({
getters: {
getNoteableData: () => ({ state: noteableState }),
},
});
wrapper = shallowMount(SidebarStatus, {
propsData: {
mediator,
},
methods: {
handleDropdownClick: handleDropdownClickMock,
},
mocks: {
$store: mockStore,
},
store,
});
};
beforeEach(() => {
handleDropdownClickMock = jest.fn();
createMediator();
createWrapper();
});
......@@ -52,15 +55,8 @@ describe('SidebarStatus', () => {
${'closed'} | ${false}
`('isOpen', ({ noteableState, isOpen }) => {
beforeEach(() => {
const mockStore = {
getters: {
getNoteableData: {
state: noteableState,
},
},
};
createMediator({ editable: true });
createWrapper(mockStore);
createWrapper({ noteableState });
});
it(`returns ${isOpen} when issue is ${noteableState}`, () => {
......@@ -76,16 +72,10 @@ describe('SidebarStatus', () => {
expect(wrapper.find(Status).exists()).toBe(true);
});
it('calls handleFormSubmission when receiving an onDropdownClick event from Status component', () => {
it('calls mediator status update when receiving an onDropdownClick event from Status component', () => {
wrapper.find(Status).vm.$emit('onDropdownClick', 'onTrack');
expect(handleDropdownClickMock).toHaveBeenCalledWith('onTrack');
expect(mediator.updateStatus).toHaveBeenCalledWith('onTrack');
});
});
it('calls handleFormSubmission when receiving an onFormSubmit event from Status component', () => {
wrapper.find(Status).vm.$emit('onDropdownClick', 'onTrack');
expect(handleDropdownClickMock).toHaveBeenCalledWith('onTrack');
});
});
......@@ -18,14 +18,15 @@ describe('Grouped metrics reports app', () => {
propsData: {
endpoint: 'metrics.json',
},
methods: {
fetchMetrics: () => {},
},
});
};
beforeEach(() => {
mockStore = new Vuex.Store(getStoreConfig());
const { actions, ...storeConfig } = getStoreConfig();
mockStore = new Vuex.Store({
...storeConfig,
actions: { ...actions, fetchMetrics: () => ({}) },
});
mountComponent();
});
......
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