Commit 6b8f6075 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'fix-karma-test-utils-master-overflow' into 'master'

CE Move serverless karma specs to jest

Closes #60154

See merge request gitlab-org/gitlab-ce!27085
parents 5d1e2a7a 2daba22b
...@@ -16,6 +16,7 @@ describe('Area component', () => { ...@@ -16,6 +16,7 @@ describe('Area component', () => {
slots: { slots: {
default: mockWidgets, default: mockWidgets,
}, },
sync: false,
}); });
}); });
...@@ -67,7 +68,7 @@ describe('Area component', () => { ...@@ -67,7 +68,7 @@ describe('Area component', () => {
const mockWidth = 233; const mockWidth = 233;
beforeEach(() => { beforeEach(() => {
spyOn(Element.prototype, 'getBoundingClientRect').and.callFake(() => ({ jest.spyOn(Element.prototype, 'getBoundingClientRect').mockImplementation(() => ({
width: mockWidth, width: mockWidth,
})); }));
areaChart.vm.onResize(); areaChart.vm.onResize();
......
...@@ -5,7 +5,7 @@ import { mockServerlessFunctions, mockServerlessFunctionsDiffEnv } from '../mock ...@@ -5,7 +5,7 @@ import { mockServerlessFunctions, mockServerlessFunctionsDiffEnv } from '../mock
import { translate } from '~/serverless/utils'; import { translate } from '~/serverless/utils';
const createComponent = (localVue, env, envName) => const createComponent = (localVue, env, envName) =>
shallowMount(environmentRowComponent, { localVue, propsData: { env, envName } }).vm; shallowMount(environmentRowComponent, { localVue, propsData: { env, envName }, sync: false }).vm;
describe('environment row component', () => { describe('environment row component', () => {
describe('default global cluster case', () => { describe('default global cluster case', () => {
......
...@@ -41,6 +41,7 @@ describe('functionDetailsComponent', () => { ...@@ -41,6 +41,7 @@ describe('functionDetailsComponent', () => {
clustersPath: '/clusters', clustersPath: '/clusters',
helpPath: '/help', helpPath: '/help',
}, },
sync: false,
}); });
expect( expect(
...@@ -68,6 +69,7 @@ describe('functionDetailsComponent', () => { ...@@ -68,6 +69,7 @@ describe('functionDetailsComponent', () => {
clustersPath: '/clusters', clustersPath: '/clusters',
helpPath: '/help', helpPath: '/help',
}, },
sync: false,
}); });
expect(component.vm.$el.querySelector('p').innerHTML.trim()).toContain('1 pod in use'); expect(component.vm.$el.querySelector('p').innerHTML.trim()).toContain('1 pod in use');
...@@ -85,6 +87,7 @@ describe('functionDetailsComponent', () => { ...@@ -85,6 +87,7 @@ describe('functionDetailsComponent', () => {
clustersPath: '/clusters', clustersPath: '/clusters',
helpPath: '/help', helpPath: '/help',
}, },
sync: false,
}); });
expect(component.vm.$el.querySelector('p').innerHTML.trim()).toContain('3 pods in use'); expect(component.vm.$el.querySelector('p').innerHTML.trim()).toContain('3 pods in use');
...@@ -102,6 +105,7 @@ describe('functionDetailsComponent', () => { ...@@ -102,6 +105,7 @@ describe('functionDetailsComponent', () => {
clustersPath: '/clusters', clustersPath: '/clusters',
helpPath: '/help', helpPath: '/help',
}, },
sync: false,
}); });
expect( expect(
......
...@@ -3,7 +3,8 @@ import { shallowMount } from '@vue/test-utils'; ...@@ -3,7 +3,8 @@ import { shallowMount } from '@vue/test-utils';
import { mockServerlessFunction } from '../mock_data'; import { mockServerlessFunction } from '../mock_data';
const createComponent = func => shallowMount(functionRowComponent, { propsData: { func } }).vm; const createComponent = func =>
shallowMount(functionRowComponent, { propsData: { func }, sync: false }).vm;
describe('functionRowComponent', () => { describe('functionRowComponent', () => {
it('Parses the function details correctly', () => { it('Parses the function details correctly', () => {
......
import Vuex from 'vuex'; import Vuex from 'vuex';
import AxiosMockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import functionsComponent from '~/serverless/components/functions.vue'; import functionsComponent from '~/serverless/components/functions.vue';
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import { createStore } from '~/serverless/store'; import { createStore } from '~/serverless/store';
...@@ -79,15 +80,19 @@ describe('functionsComponent', () => { ...@@ -79,15 +80,19 @@ describe('functionsComponent', () => {
); );
}); });
it('should render the functions list', () => { fit('should render the functions list', () => {
const statusPath = 'statusPath';
const axiosMock = new AxiosMockAdapter(axios);
axiosMock.onGet(statusPath).reply(200);
component = shallowMount(functionsComponent, { component = shallowMount(functionsComponent, {
localVue, localVue,
store, store,
propsData: { propsData: {
installed: true, installed: true,
clustersPath: '', clustersPath: 'clustersPath',
helpPath: '', helpPath: 'helpPath',
statusPath: '', statusPath,
}, },
sync: false, sync: false,
}); });
......
...@@ -8,6 +8,7 @@ const createComponent = missingData => ...@@ -8,6 +8,7 @@ const createComponent = missingData =>
helpPath: '/help', helpPath: '/help',
missingData, missingData,
}, },
sync: false,
}).vm; }).vm;
describe('missingPrometheusComponent', () => { describe('missingPrometheusComponent', () => {
......
...@@ -6,6 +6,7 @@ const createComponent = count => ...@@ -6,6 +6,7 @@ const createComponent = count =>
propsData: { propsData: {
count, count,
}, },
sync: false,
}).vm; }).vm;
describe('podBoxComponent', () => { describe('podBoxComponent', () => {
......
...@@ -7,6 +7,7 @@ const createComponent = uri => ...@@ -7,6 +7,7 @@ const createComponent = uri =>
propsData: { propsData: {
uri, uri,
}, },
sync: false,
}).vm; }).vm;
describe('urlComponent', () => { describe('urlComponent', () => {
......
...@@ -32,7 +32,9 @@ describe('ServerlessActions', () => { ...@@ -32,7 +32,9 @@ describe('ServerlessActions', () => {
it('should successfully retry', done => { it('should successfully retry', done => {
const endpoint = '/functions'; const endpoint = '/functions';
const mock = new MockAdapter(axios); const mock = new MockAdapter(axios);
mock.onGet(endpoint).reply(statusCodes.NO_CONTENT); mock
.onGet(endpoint)
.reply(() => new Promise(resolve => setTimeout(() => resolve(200), Infinity)));
testAction( testAction(
fetchFunctions, fetchFunctions,
......
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