Commit a6484733 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'xanf-vtu-v1-ee-methods' into 'master'

Upgrading VTU to v1: Fix deprecated `methods` in various `ee` specs

See merge request gitlab-org/gitlab!50503
parents d2e3ad54 e9da4323
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