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/monitoring/store/getters_spec.js')
-rw-r--r--spec/frontend/monitoring/store/getters_spec.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/frontend/monitoring/store/getters_spec.js b/spec/frontend/monitoring/store/getters_spec.js
index 097a5ca7f7c..263050b462f 100644
--- a/spec/frontend/monitoring/store/getters_spec.js
+++ b/spec/frontend/monitoring/store/getters_spec.js
@@ -3,6 +3,7 @@ import mutations from '~/monitoring/stores/mutations';
import * as types from '~/monitoring/stores/mutation_types';
import { metricStates } from '~/monitoring/constants';
import {
+ environmentData,
metricsDashboardPayload,
mockedEmptyResult,
mockedQueryResultPayload,
@@ -214,4 +215,58 @@ describe('Monitoring store Getters', () => {
});
});
});
+
+ describe('filteredEnvironments', () => {
+ let state;
+ const setupState = (initState = {}) => {
+ state = {
+ ...state,
+ ...initState,
+ };
+ };
+
+ beforeAll(() => {
+ setupState({
+ environments: environmentData,
+ });
+ });
+
+ afterAll(() => {
+ state = null;
+ });
+
+ [
+ {
+ input: '',
+ output: 17,
+ },
+ {
+ input: ' ',
+ output: 17,
+ },
+ {
+ input: null,
+ output: 17,
+ },
+ {
+ input: 'does-not-exist',
+ output: 0,
+ },
+ {
+ input: 'noop-branch-',
+ output: 15,
+ },
+ {
+ input: 'noop-branch-9',
+ output: 1,
+ },
+ ].forEach(({ input, output }) => {
+ it(`filteredEnvironments returns ${output} items for ${input}`, () => {
+ setupState({
+ environmentsSearchTerm: input,
+ });
+ expect(getters.filteredEnvironments(state).length).toBe(output);
+ });
+ });
+ });
});