Commit 13711666 authored by Natalia Tepluhina's avatar Natalia Tepluhina

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

Upgrading VTU to v1: Remove deprecated `setMethods` method from spec

See merge request gitlab-org/gitlab!50517
parents c5112670 3f9c89df
import { nextTick } from 'vue';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import EpicsSelect from 'ee/vue_shared/components/sidebar/epics_select/base.vue';
import BoardSidebarEpicSelect from 'ee/boards/components/sidebar/board_sidebar_epic_select.vue'; import BoardSidebarEpicSelect from 'ee/boards/components/sidebar/board_sidebar_epic_select.vue';
import { stubComponent } from 'helpers/stub_component';
import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue'; import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue';
import { createStore } from '~/boards/stores'; import { createStore } from '~/boards/stores';
...@@ -20,7 +23,10 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => { ...@@ -20,7 +23,10 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => {
wrapper = null; wrapper = null;
}); });
let epicsSelectHandleEditClick;
const createWrapper = () => { const createWrapper = () => {
epicsSelectHandleEditClick = jest.fn();
store = createStore(); store = createStore();
jest.spyOn(store, 'dispatch').mockImplementation(() => {}); jest.spyOn(store, 'dispatch').mockImplementation(() => {});
wrapper = shallowMount(BoardSidebarEpicSelect, { wrapper = shallowMount(BoardSidebarEpicSelect, {
...@@ -30,7 +36,12 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => { ...@@ -30,7 +36,12 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => {
canUpdate: true, canUpdate: true,
}, },
stubs: { stubs: {
'board-editable-item': BoardEditableItem, BoardEditableItem,
EpicsSelect: stubComponent(EpicsSelect, {
methods: {
handleEditClick: epicsSelectHandleEditClick,
},
}),
}, },
}); });
...@@ -50,17 +61,16 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => { ...@@ -50,17 +61,16 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => {
it('expands the dropdown when editing', () => { it('expands the dropdown when editing', () => {
createWrapper(); createWrapper();
wrapper.setMethods({ openEpicsDropdown: jest.fn() });
findItemWrapper().vm.$emit('open'); findItemWrapper().vm.$emit('open');
expect(wrapper.vm.openEpicsDropdown).toHaveBeenCalled(); expect(epicsSelectHandleEditClick).toHaveBeenCalled();
}); });
describe('when epic is selected', () => { describe('when epic is selected', () => {
beforeEach(async () => { beforeEach(() => {
createWrapper(); createWrapper();
jest.spyOn(wrapper.vm, 'setActiveIssueEpic').mockImplementation(() => TEST_EPIC); jest.spyOn(wrapper.vm, 'setActiveIssueEpic').mockImplementation(() => TEST_EPIC);
findEpicSelect().vm.$emit('onEpicSelect', { ...TEST_EPIC, id: TEST_EPIC_ID }); findEpicSelect().vm.$emit('onEpicSelect', { ...TEST_EPIC, id: TEST_EPIC_ID });
await wrapper.vm.$nextTick(); return nextTick();
}); });
it('collapses sidebar and renders epic title', () => { it('collapses sidebar and renders epic title', () => {
...@@ -81,11 +91,11 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => { ...@@ -81,11 +91,11 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => {
}); });
describe('when no epic is selected', () => { describe('when no epic is selected', () => {
beforeEach(async () => { beforeEach(() => {
createWrapper(); createWrapper();
jest.spyOn(wrapper.vm, 'setActiveIssueEpic').mockImplementation(() => null); jest.spyOn(wrapper.vm, 'setActiveIssueEpic').mockImplementation(() => null);
findEpicSelect().vm.$emit('onEpicSelect', null); findEpicSelect().vm.$emit('onEpicSelect', null);
await wrapper.vm.$nextTick(); return nextTick();
}); });
it('collapses sidebar and renders "None"', () => { it('collapses sidebar and renders "None"', () => {
...@@ -101,14 +111,14 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => { ...@@ -101,14 +111,14 @@ describe('ee/boards/components/sidebar/board_sidebar_epic_select.vue', () => {
describe('when the mutation fails', () => { describe('when the mutation fails', () => {
const issueWithEpic = { ...TEST_ISSUE, epic: TEST_EPIC }; const issueWithEpic = { ...TEST_ISSUE, epic: TEST_EPIC };
beforeEach(async () => { beforeEach(() => {
createWrapper(); createWrapper();
store.state.issues = { [TEST_ISSUE.id]: { ...issueWithEpic } }; store.state.issues = { [TEST_ISSUE.id]: { ...issueWithEpic } };
jest.spyOn(wrapper.vm, 'setActiveIssueEpic').mockImplementation(() => { jest.spyOn(wrapper.vm, 'setActiveIssueEpic').mockImplementation(() => {
throw new Error(['failed mutation']); throw new Error(['failed mutation']);
}); });
findEpicSelect().vm.$emit('onEpicSelect', {}); findEpicSelect().vm.$emit('onEpicSelect', {});
await wrapper.vm.$nextTick(); return nextTick();
}); });
it('collapses sidebar and renders former issue epic', () => { it('collapses sidebar and renders former issue epic', () => {
......
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