diff options
Diffstat (limited to 'spec/frontend/pipelines/pipeline_graph')
-rw-r--r-- | spec/frontend/pipelines/pipeline_graph/utils_spec.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/spec/frontend/pipelines/pipeline_graph/utils_spec.js b/spec/frontend/pipelines/pipeline_graph/utils_spec.js index 5816bc06fe3..d6b13da3c3a 100644 --- a/spec/frontend/pipelines/pipeline_graph/utils_spec.js +++ b/spec/frontend/pipelines/pipeline_graph/utils_spec.js @@ -1,4 +1,5 @@ -import { createJobsHash, generateJobNeedsDict } from '~/pipelines/utils'; +import { createJobsHash, generateJobNeedsDict, getPipelineDefaultTab } from '~/pipelines/utils'; +import { TAB_QUERY_PARAM, validPipelineTabNames } from '~/pipelines/constants'; describe('utils functions', () => { const jobName1 = 'build_1'; @@ -169,4 +170,21 @@ describe('utils functions', () => { }); }); }); + + describe('getPipelineDefaultTab', () => { + const baseUrl = 'http://gitlab.com/user/multi-projects-small/-/pipelines/332/'; + it('returns null if there was no `tab` params', () => { + expect(getPipelineDefaultTab(baseUrl)).toBe(null); + }); + + it('returns null if there was no valid tab param', () => { + expect(getPipelineDefaultTab(`${baseUrl}?${TAB_QUERY_PARAM}=invalid`)).toBe(null); + }); + + it('returns the correct tab name if present', () => { + validPipelineTabNames.forEach((tabName) => { + expect(getPipelineDefaultTab(`${baseUrl}?${TAB_QUERY_PARAM}=${tabName}`)).toBe(tabName); + }); + }); + }); }); |