Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/serverless')
-rw-r--r--spec/frontend/serverless/components/__snapshots__/empty_state_spec.js.snap20
-rw-r--r--spec/frontend/serverless/components/empty_state_spec.js25
-rw-r--r--spec/frontend/serverless/components/function_details_spec.js10
-rw-r--r--spec/frontend/serverless/components/functions_spec.js57
-rw-r--r--spec/frontend/serverless/components/missing_prometheus_spec.js20
-rw-r--r--spec/frontend/serverless/survey_banner_spec.js2
-rw-r--r--spec/frontend/serverless/utils.js4
7 files changed, 67 insertions, 71 deletions
diff --git a/spec/frontend/serverless/components/__snapshots__/empty_state_spec.js.snap b/spec/frontend/serverless/components/__snapshots__/empty_state_spec.js.snap
new file mode 100644
index 00000000000..22689080063
--- /dev/null
+++ b/spec/frontend/serverless/components/__snapshots__/empty_state_spec.js.snap
@@ -0,0 +1,20 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`EmptyStateComponent should render content 1`] = `
+"<section class=\\"row empty-state text-center\\">
+ <div class=\\"col-12\\">
+ <div class=\\"svg-250 svg-content\\"><img src=\\"/image.svg\\" alt=\\"Getting started with serverless\\" class=\\"gl-max-w-full\\"></div>
+ </div>
+ <div class=\\"col-12\\">
+ <div class=\\"text-content gl-mx-auto gl-my-0 gl-p-5\\">
+ <h1 class=\\"h4\\">Getting started with serverless</h1>
+ <p>In order to start using functions as a service, you must first install Knative on your Kubernetes cluster. <gl-link-stub href=\\"/help\\">More information</gl-link-stub>
+ </p>
+ <div>
+ <gl-button-stub category=\\"primary\\" variant=\\"success\\" size=\\"medium\\" icon=\\"\\" href=\\"/clusters\\">Install Knative</gl-button-stub>
+ <!---->
+ </div>
+ </div>
+ </div>
+</section>"
+`;
diff --git a/spec/frontend/serverless/components/empty_state_spec.js b/spec/frontend/serverless/components/empty_state_spec.js
new file mode 100644
index 00000000000..daa1576a4ec
--- /dev/null
+++ b/spec/frontend/serverless/components/empty_state_spec.js
@@ -0,0 +1,25 @@
+import { GlEmptyState, GlSprintf } from '@gitlab/ui';
+import { shallowMount } from '@vue/test-utils';
+import { createStore } from '~/serverless/store';
+import EmptyStateComponent from '~/serverless/components/empty_state.vue';
+
+describe('EmptyStateComponent', () => {
+ let wrapper;
+
+ beforeEach(() => {
+ const store = createStore({
+ clustersPath: '/clusters',
+ helpPath: '/help',
+ emptyImagePath: '/image.svg',
+ });
+ wrapper = shallowMount(EmptyStateComponent, { store, stubs: { GlEmptyState, GlSprintf } });
+ });
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ it('should render content', () => {
+ expect(wrapper.html()).toMatchSnapshot();
+ });
+});
diff --git a/spec/frontend/serverless/components/function_details_spec.js b/spec/frontend/serverless/components/function_details_spec.js
index 40d2bbb0291..248dd418941 100644
--- a/spec/frontend/serverless/components/function_details_spec.js
+++ b/spec/frontend/serverless/components/function_details_spec.js
@@ -13,7 +13,7 @@ describe('functionDetailsComponent', () => {
localVue = createLocalVue();
localVue.use(Vuex);
- store = createStore();
+ store = createStore({ clustersPath: '/clusters', helpPath: '/help' });
});
afterEach(() => {
@@ -38,8 +38,6 @@ describe('functionDetailsComponent', () => {
propsData: {
func: serviceStub,
hasPrometheus: false,
- clustersPath: '/clusters',
- helpPath: '/help',
},
});
@@ -65,8 +63,6 @@ describe('functionDetailsComponent', () => {
propsData: {
func: serviceStub,
hasPrometheus: false,
- clustersPath: '/clusters',
- helpPath: '/help',
},
});
@@ -82,8 +78,6 @@ describe('functionDetailsComponent', () => {
propsData: {
func: serviceStub,
hasPrometheus: false,
- clustersPath: '/clusters',
- helpPath: '/help',
},
});
@@ -99,8 +93,6 @@ describe('functionDetailsComponent', () => {
propsData: {
func: serviceStub,
hasPrometheus: false,
- clustersPath: '/clusters',
- helpPath: '/help',
},
});
diff --git a/spec/frontend/serverless/components/functions_spec.js b/spec/frontend/serverless/components/functions_spec.js
index 8db04409357..0fca027fe56 100644
--- a/spec/frontend/serverless/components/functions_spec.js
+++ b/spec/frontend/serverless/components/functions_spec.js
@@ -25,55 +25,31 @@ describe('functionsComponent', () => {
localVue = createLocalVue();
localVue.use(Vuex);
- store = createStore();
+ store = createStore({});
});
afterEach(() => {
- component.vm.$destroy();
+ component.destroy();
axiosMock.restore();
});
it('should render empty state when Knative is not installed', () => {
store.dispatch('receiveFunctionsSuccess', { knative_installed: false });
- component = shallowMount(functionsComponent, {
- localVue,
- store,
- propsData: {
- clustersPath: '',
- helpPath: '',
- statusPath: '',
- },
- });
+ component = shallowMount(functionsComponent, { localVue, store });
expect(component.find(EmptyState).exists()).toBe(true);
});
it('should render a loading component', () => {
store.dispatch('requestFunctionsLoading');
- component = shallowMount(functionsComponent, {
- localVue,
- store,
- propsData: {
- clustersPath: '',
- helpPath: '',
- statusPath: '',
- },
- });
+ component = shallowMount(functionsComponent, { localVue, store });
expect(component.find(GlLoadingIcon).exists()).toBe(true);
});
it('should render empty state when there is no function data', () => {
store.dispatch('receiveFunctionsNoDataSuccess', { knative_installed: true });
- component = shallowMount(functionsComponent, {
- localVue,
- store,
- propsData: {
- clustersPath: '',
- helpPath: '',
- statusPath: '',
- },
- });
+ component = shallowMount(functionsComponent, { localVue, store });
expect(
component.vm.$el
@@ -91,30 +67,17 @@ describe('functionsComponent', () => {
...mockServerlessFunctions,
knative_installed: 'checking',
});
- component = shallowMount(functionsComponent, {
- localVue,
- store,
- propsData: {
- clustersPath: '',
- helpPath: '',
- statusPath: '',
- },
- });
+
+ component = shallowMount(functionsComponent, { localVue, store });
expect(component.find('.js-functions-wrapper').exists()).toBe(true);
expect(component.find('.js-functions-loader').exists()).toBe(true);
});
it('should render the functions list', () => {
- component = shallowMount(functionsComponent, {
- localVue,
- store,
- propsData: {
- clustersPath: 'clustersPath',
- helpPath: 'helpPath',
- statusPath,
- },
- });
+ store = createStore({ clustersPath: 'clustersPath', helpPath: 'helpPath', statusPath });
+
+ component = shallowMount(functionsComponent, { localVue, store });
component.vm.$store.dispatch('receiveFunctionsSuccess', mockServerlessFunctions);
diff --git a/spec/frontend/serverless/components/missing_prometheus_spec.js b/spec/frontend/serverless/components/missing_prometheus_spec.js
index 90730765f7c..9ca4a45dd5f 100644
--- a/spec/frontend/serverless/components/missing_prometheus_spec.js
+++ b/spec/frontend/serverless/components/missing_prometheus_spec.js
@@ -1,25 +1,23 @@
import { GlDeprecatedButton } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
+import { createStore } from '~/serverless/store';
import missingPrometheusComponent from '~/serverless/components/missing_prometheus.vue';
-const createComponent = missingData =>
- shallowMount(missingPrometheusComponent, {
- propsData: {
- clustersPath: '/clusters',
- helpPath: '/help',
- missingData,
- },
- });
-
describe('missingPrometheusComponent', () => {
let wrapper;
+ const createComponent = missingData => {
+ const store = createStore({ clustersPath: '/clusters', helpPath: '/help' });
+
+ wrapper = shallowMount(missingPrometheusComponent, { store, propsData: { missingData } });
+ };
+
afterEach(() => {
wrapper.destroy();
});
it('should render missing prometheus message', () => {
- wrapper = createComponent(false);
+ createComponent(false);
const { vm } = wrapper;
expect(vm.$el.querySelector('.state-description').innerHTML.trim()).toContain(
@@ -30,7 +28,7 @@ describe('missingPrometheusComponent', () => {
});
it('should render no prometheus data message', () => {
- wrapper = createComponent(true);
+ createComponent(true);
const { vm } = wrapper;
expect(vm.$el.querySelector('.state-description').innerHTML.trim()).toContain(
diff --git a/spec/frontend/serverless/survey_banner_spec.js b/spec/frontend/serverless/survey_banner_spec.js
index 15e9c6ec350..29b36fb9b5f 100644
--- a/spec/frontend/serverless/survey_banner_spec.js
+++ b/spec/frontend/serverless/survey_banner_spec.js
@@ -1,7 +1,7 @@
import { shallowMount } from '@vue/test-utils';
import Cookies from 'js-cookie';
-import SurveyBanner from '~/serverless/survey_banner.vue';
import { GlBanner } from '@gitlab/ui';
+import SurveyBanner from '~/serverless/survey_banner.vue';
describe('Knative survey banner', () => {
let wrapper;
diff --git a/spec/frontend/serverless/utils.js b/spec/frontend/serverless/utils.js
index 5ce2e37d493..ba451b7d573 100644
--- a/spec/frontend/serverless/utils.js
+++ b/spec/frontend/serverless/utils.js
@@ -1,3 +1,4 @@
+// eslint-disable-next-line import/prefer-default-export
export const adjustMetricQuery = data => {
const updatedMetric = data.metrics;
@@ -15,6 +16,3 @@ export const adjustMetricQuery = data => {
updatedMetric.queries = queries;
return updatedMetric;
};
-
-// prevent babel-plugin-rewire from generating an invalid default during karma tests
-export default () => {};