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