diff options
Diffstat (limited to 'spec/frontend/projects/settings/utils_spec.js')
| -rw-r--r-- | spec/frontend/projects/settings/utils_spec.js | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/spec/frontend/projects/settings/utils_spec.js b/spec/frontend/projects/settings/utils_spec.js index 319aa4000b5..d85f43778b1 100644 --- a/spec/frontend/projects/settings/utils_spec.js +++ b/spec/frontend/projects/settings/utils_spec.js @@ -1,4 +1,5 @@ -import { getAccessLevels } from '~/projects/settings/utils'; +import { getAccessLevels, generateRefDestinationPath } from '~/projects/settings/utils'; +import setWindowLocation from 'helpers/set_window_location_helper'; import { pushAccessLevelsMockResponse, pushAccessLevelsMockResult } from './mock_data'; describe('Utils', () => { @@ -8,4 +9,25 @@ describe('Utils', () => { expect(pushAccessLevels).toEqual(pushAccessLevelsMockResult); }); }); + + describe('generateRefDestinationPath', () => { + const projectRootPath = 'http://test.host/root/Project1'; + const settingsCi = '-/settings/ci_cd'; + + it.each` + currentPath | selectedRef | result + ${`${projectRootPath}`} | ${undefined} | ${`${projectRootPath}`} + ${`${projectRootPath}`} | ${'test'} | ${`${projectRootPath}`} + ${`${projectRootPath}/${settingsCi}`} | ${'test'} | ${`${projectRootPath}/${settingsCi}?ref=test`} + ${`${projectRootPath}/${settingsCi}`} | ${'branch-hyphen'} | ${`${projectRootPath}/${settingsCi}?ref=branch-hyphen`} + ${`${projectRootPath}/${settingsCi}`} | ${'test/branch'} | ${`${projectRootPath}/${settingsCi}?ref=test%2Fbranch`} + ${`${projectRootPath}/${settingsCi}`} | ${'test/branch-hyphen'} | ${`${projectRootPath}/${settingsCi}?ref=test%2Fbranch-hyphen`} + `( + 'generates the correct destination path for the `$selectedRef` ref and current url $currentPath by outputting $result', + ({ currentPath, selectedRef, result }) => { + setWindowLocation(currentPath); + expect(generateRefDestinationPath(selectedRef)).toBe(result); + }, + ); + }); }); |
