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