diff options
author | Eric Eastwood <contact@ericeastwood.com> | 2017-08-25 16:05:32 -0500 |
---|---|---|
committer | Eric Eastwood <contact@ericeastwood.com> | 2017-08-25 16:38:13 -0500 |
commit | 18bcbe30c955030391c47d8211360991f75479a5 (patch) | |
tree | 17bf45cb297f1e0bd0ff727180ef0bf4f7ea8dad /spec | |
parent | 2352f187a601be70eaeb795b7ff8c9199726debf (diff) | |
download | gitlab-ce-fix-repo-editor-regex.tar.gz |
Move repo specific dropdown label processing into the configfix-repo-editor-regex
See
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/13390#note_38460888
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/13428#note_38462176
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/gl_dropdown_spec.js | 23 | ||||
-rw-r--r-- | spec/javascripts/repo/helpers/get_safe_branch_name_helper_spec.js | 13 |
2 files changed, 25 insertions, 11 deletions
diff --git a/spec/javascripts/gl_dropdown_spec.js b/spec/javascripts/gl_dropdown_spec.js index d97837de20b..09e32a1f0b1 100644 --- a/spec/javascripts/gl_dropdown_spec.js +++ b/spec/javascripts/gl_dropdown_spec.js @@ -302,25 +302,26 @@ import '~/lib/utils/url_utility'; expect(input.text).toHaveBeenCalledWith(branch); }); - it('does not replace repeated dashes with single dashes', () => { - const branch = 'some--branch--name'; - options.inputFieldName = branch; + it('processes the text via function options.updateLabel if available', () => { + const branch = 'bran1ch'; + gitLabDropdownInput.options.updateLabel = label => `${label}:something`; + spyOn(gitLabDropdownInput.options, 'updateLabel').and.callThrough(); + event.currentTarget.value = branch; GitLabDropdownInput.prototype.setToggleText.call(gitLabDropdownInput, event); - expect(gitLabDropdownInput.cb).toHaveBeenCalledWith(options.fieldName, branch, {}, true); - expect(input.text).toHaveBeenCalledWith(branch); + expect(gitLabDropdownInput.options.updateLabel).toHaveBeenCalledWith(branch); + expect(input.text).toHaveBeenCalledWith(`${branch}:something`); }); - it('removes non-alphanumeric characters', () => { - const branch = '$some#-branch!'; - const val = 'some-branch'; - options.inputFieldName = branch; + it('processes the text via string options.updateLabel if available', () => { + const branch = 'bran1ch'; + gitLabDropdownInput.options.updateLabel = 'override'; + event.currentTarget.value = branch; GitLabDropdownInput.prototype.setToggleText.call(gitLabDropdownInput, event); - expect(gitLabDropdownInput.cb).toHaveBeenCalledWith(options.fieldName, val, {}, true); - expect(input.text).toHaveBeenCalledWith(val); + expect(input.text).toHaveBeenCalledWith('override'); }); }); diff --git a/spec/javascripts/repo/helpers/get_safe_branch_name_helper_spec.js b/spec/javascripts/repo/helpers/get_safe_branch_name_helper_spec.js new file mode 100644 index 00000000000..f426227fa60 --- /dev/null +++ b/spec/javascripts/repo/helpers/get_safe_branch_name_helper_spec.js @@ -0,0 +1,13 @@ +import getSafeBranchName from '~/repo/helpers/get_safe_branch_name_helper'; + +describe('getSafeBranchName', () => { + it('does not replace repeated dashes with single dashes', () => { + const branch = 'some--branch--name'; + expect(getSafeBranchName(branch)).toBe(branch); + }); + + it('removes non-alphanumeric characters', () => { + const branch = '$some#-branch!'; + expect(getSafeBranchName(branch)).toBe('some-branch'); + }); +}); |