summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bennett <lukeeeebennettplus@gmail.com>2019-04-07 04:00:28 +0100
committerLuke Bennett <lbennett@gitlab.com>2019-04-07 12:25:12 +0100
commit083e896d5e8651c082349ed5f82597fa95d3265d (patch)
tree2001db400f6a708dd5d5380bf023d8219af42c42
parent97b8853d617060fe38c861360181ef83321727e2 (diff)
downloadgitlab-ce-083e896d5e8651c082349ed5f82597fa95d3265d.tar.gz
Fix unmocked requests in serverless tests
-rw-r--r--spec/frontend/serverless/components/area_spec.js2
-rw-r--r--spec/frontend/serverless/components/function_row_spec.js3
-rw-r--r--spec/frontend/serverless/components/functions_spec.js15
-rw-r--r--spec/frontend/serverless/store/actions_spec.js4
4 files changed, 16 insertions, 8 deletions
diff --git a/spec/frontend/serverless/components/area_spec.js b/spec/frontend/serverless/components/area_spec.js
index 2be6ac3d268..8b6f664ae25 100644
--- a/spec/frontend/serverless/components/area_spec.js
+++ b/spec/frontend/serverless/components/area_spec.js
@@ -67,7 +67,7 @@ describe('Area component', () => {
const mockWidth = 233;
beforeEach(() => {
- spyOn(Element.prototype, 'getBoundingClientRect').and.callFake(() => ({
+ jest.spyOn(Element.prototype, 'getBoundingClientRect').mockImplementation(() => ({
width: mockWidth,
}));
areaChart.vm.onResize();
diff --git a/spec/frontend/serverless/components/function_row_spec.js b/spec/frontend/serverless/components/function_row_spec.js
index 3987e1753bd..414fdc5cd82 100644
--- a/spec/frontend/serverless/components/function_row_spec.js
+++ b/spec/frontend/serverless/components/function_row_spec.js
@@ -3,7 +3,8 @@ import { shallowMount } from '@vue/test-utils';
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', () => {
it('Parses the function details correctly', () => {
diff --git a/spec/frontend/serverless/components/functions_spec.js b/spec/frontend/serverless/components/functions_spec.js
index c32978ea58a..5533de1a70a 100644
--- a/spec/frontend/serverless/components/functions_spec.js
+++ b/spec/frontend/serverless/components/functions_spec.js
@@ -1,5 +1,6 @@
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 { createLocalVue, shallowMount } from '@vue/test-utils';
import { createStore } from '~/serverless/store';
@@ -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, {
localVue,
store,
propsData: {
installed: true,
- clustersPath: '',
- helpPath: '',
- statusPath: '',
+ clustersPath: 'clustersPath',
+ helpPath: 'helpPath',
+ statusPath,
},
sync: false,
});
diff --git a/spec/frontend/serverless/store/actions_spec.js b/spec/frontend/serverless/store/actions_spec.js
index 602798573e9..aac57c75a4f 100644
--- a/spec/frontend/serverless/store/actions_spec.js
+++ b/spec/frontend/serverless/store/actions_spec.js
@@ -32,7 +32,9 @@ describe('ServerlessActions', () => {
it('should successfully retry', done => {
const endpoint = '/functions';
const mock = new MockAdapter(axios);
- mock.onGet(endpoint).reply(statusCodes.NO_CONTENT);
+ mock
+ .onGet(endpoint)
+ .reply(() => new Promise(resolve => setTimeout(() => resolve(200), Infinity)));
testAction(
fetchFunctions,