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/ci_variable_list/utils_spec.js')
-rw-r--r--spec/frontend/ci_variable_list/utils_spec.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/spec/frontend/ci_variable_list/utils_spec.js b/spec/frontend/ci_variable_list/utils_spec.js
index 1676e786515..081c399792f 100644
--- a/spec/frontend/ci_variable_list/utils_spec.js
+++ b/spec/frontend/ci_variable_list/utils_spec.js
@@ -7,12 +7,13 @@ import { allEnvironments } from '~/ci_variable_list/constants';
describe('utils', () => {
const environments = ['dev', 'prod'];
+ const newEnvironments = ['staging'];
describe('createJoinedEnvironments', () => {
it('returns only `environments` if `variables` argument is undefined', () => {
const variables = undefined;
- expect(createJoinedEnvironments(variables, environments)).toEqual(environments);
+ expect(createJoinedEnvironments(variables, environments, [])).toEqual(environments);
});
it('returns a list of environments and environment scopes taken from variables in alphabetical order', () => {
@@ -21,7 +22,7 @@ describe('utils', () => {
const variables = [{ environmentScope: envScope1 }, { environmentScope: envScope2 }];
- expect(createJoinedEnvironments(variables, environments)).toEqual([
+ expect(createJoinedEnvironments(variables, environments, [])).toEqual([
environments[0],
envScope1,
envScope2,
@@ -29,13 +30,22 @@ describe('utils', () => {
]);
});
+ it('returns combined list with new environments included', () => {
+ const variables = undefined;
+
+ expect(createJoinedEnvironments(variables, environments, newEnvironments)).toEqual([
+ ...environments,
+ ...newEnvironments,
+ ]);
+ });
+
it('removes duplicate environments', () => {
const envScope1 = environments[0];
const envScope2 = 'new2';
const variables = [{ environmentScope: envScope1 }, { environmentScope: envScope2 }];
- expect(createJoinedEnvironments(variables, environments)).toEqual([
+ expect(createJoinedEnvironments(variables, environments, [])).toEqual([
environments[0],
envScope2,
environments[1],