Commit 341cfbae authored by Illya Klymov's avatar Illya Klymov

Fix karma tests in future version of VTU

Fixes failing tests in @vue/test-utils 1.0.0-beta.30
parent 7213dc5f
......@@ -63,7 +63,7 @@ describe('EE Approvlas MRRulesHiddenInputs', () => {
it('is empty', () => {
factory();
expect(wrapper.html()).toBeUndefined();
expect(wrapper.isEmpty()).toBe(true);
});
});
......
......@@ -50,7 +50,6 @@ const createComponent = ({
store,
stubs: {
'tree-item': true,
'gl-button': GlButton,
},
propsData: {
parentItem,
......@@ -350,13 +349,13 @@ describe('RelatedItemsTree', () => {
});
it('renders `Show more` link', () => {
expect(wrapper.find('button').text()).toBe('Show more');
expect(wrapper.find(GlButton).text()).toBe('Show more');
});
it('calls `handleShowMoreClick` when `Show more` link is clicked', () => {
spyOn(wrapper.vm, 'handleShowMoreClick');
wrapper.find('button').trigger('click');
wrapper.find(GlButton).vm.$emit('click');
expect(wrapper.vm.handleShowMoreClick).toHaveBeenCalled();
});
......
import { shallowMount, createLocalVue } from '@vue/test-utils';
import VirtualList from 'vue-virtual-scroll-list';
import epicsListSectionComponent from 'ee/roadmap/components/epics_list_section.vue';
import EpicItem from 'ee/roadmap/components/epic_item.vue';
import createStore from 'ee/roadmap/store';
import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils';
import {
......@@ -46,8 +47,8 @@ const createComponent = ({
localVue,
store,
stubs: {
'epic-item': false,
'virtual-list': false,
EpicItem: false,
VirtualList: false,
},
propsData: {
presetType,
......@@ -150,12 +151,15 @@ describe('EpicsListSectionComponent', () => {
});
describe('getEmptyRowContainerStyles', () => {
it('returns empty object when there are no epics available to render', () => {
it('returns empty object when there are no epics available to render', done => {
wrapper.setProps({
epics: [],
});
expect(wrapper.vm.getEmptyRowContainerStyles()).toEqual({});
wrapper.vm.$nextTick(() => {
expect(wrapper.vm.getEmptyRowContainerStyles()).toEqual({});
done();
});
});
it('returns object containing `height` when there epics available to render', () => {
......@@ -211,10 +215,13 @@ describe('EpicsListSectionComponent', () => {
expect(wrapper.vm.$el.classList.contains('epics-list-section')).toBe(true);
});
it('renders virtual-list when roadmapBufferedRendering is `true` and `epics.length` is more than `bufferSize`', () => {
it('renders virtual-list when roadmapBufferedRendering is `true` and `epics.length` is more than `bufferSize`', done => {
wrapper.vm.setBufferSize(5);
expect(wrapper.find('virtuallist-stub').exists()).toBe(true);
wrapper.vm.$nextTick(() => {
expect(wrapper.find(VirtualList).exists()).toBe(true);
done();
});
});
it('renders epic-item when roadmapBufferedRendering is `false`', () => {
......@@ -222,7 +229,7 @@ describe('EpicsListSectionComponent', () => {
roadmapBufferedRendering: false,
});
expect(wrapperFlagOff.find('epicitem-stub').exists()).toBe(true);
expect(wrapperFlagOff.find(EpicItem).exists()).toBe(true);
wrapperFlagOff.destroy();
});
......@@ -230,7 +237,7 @@ describe('EpicsListSectionComponent', () => {
it('renders epic-item when roadmapBufferedRendering is `true` and `epics.length` is less than `bufferSize`', () => {
wrapper.vm.setBufferSize(50);
expect(wrapper.find('epicitem-stub').exists()).toBe(true);
expect(wrapper.find(EpicItem).exists()).toBe(true);
});
it('renders empty row element when `epics.length` is less than `bufferSize`', () => {
......
......@@ -68,7 +68,7 @@ describe('diffs/components/app', () => {
});
describe('fetch diff methods', () => {
beforeEach(() => {
beforeEach(done => {
const fetchResolver = () => {
store.state.diffs.retrievingBatches = false;
return Promise.resolve();
......@@ -82,6 +82,7 @@ describe('diffs/components/app', () => {
spyOn(wrapper.vm, 'startRenderDiffsQueue');
spyOn(wrapper.vm, 'unwatchDiscussions');
store.state.diffs.retrievingBatches = true;
wrapper.vm.$nextTick(done);
});
it('calls fetchDiffFiles if diffsBatchLoad is not enabled', done => {
......@@ -99,30 +100,32 @@ describe('diffs/components/app', () => {
});
});
it('calls batch methods if diffsBatchLoad is enabled, and not latest version', () => {
it('calls batch methods if diffsBatchLoad is enabled, and not latest version', done => {
wrapper.vm.glFeatures.diffsBatchLoad = true;
wrapper.vm.isLatestVersion = () => false;
wrapper.vm.fetchData(false);
expect(wrapper.vm.fetchDiffFiles).not.toHaveBeenCalled();
wrapper.vm.$nextTick(() => {
setTimeout(() => {
expect(wrapper.vm.startRenderDiffsQueue).toHaveBeenCalled();
expect(wrapper.vm.fetchDiffFilesMeta).toHaveBeenCalled();
expect(wrapper.vm.fetchDiffFilesBatch).toHaveBeenCalled();
expect(wrapper.vm.unwatchDiscussions).toHaveBeenCalled();
done();
});
});
it('calls batch methods if diffsBatchLoad is enabled, and latest version', () => {
it('calls batch methods if diffsBatchLoad is enabled, and latest version', done => {
wrapper.vm.glFeatures.diffsBatchLoad = true;
wrapper.vm.fetchData(false);
expect(wrapper.vm.fetchDiffFiles).not.toHaveBeenCalled();
wrapper.vm.$nextTick(() => {
setTimeout(() => {
expect(wrapper.vm.startRenderDiffsQueue).toHaveBeenCalled();
expect(wrapper.vm.fetchDiffFilesMeta).toHaveBeenCalled();
expect(wrapper.vm.fetchDiffFilesBatch).toHaveBeenCalled();
expect(wrapper.vm.unwatchDiscussions).toHaveBeenCalled();
done();
});
});
});
......
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