diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2018-09-07 10:20:27 +0000 |
---|---|---|
committer | Tim Zallmann <tzallmann@gitlab.com> | 2018-09-07 10:20:27 +0000 |
commit | 44cb8a7407d3c9df958328088c914c5bedea284f (patch) | |
tree | 284d9d30036558b8d0be13ec8ba53368e52f6322 /spec/javascripts/lib/utils | |
parent | 3276e88bd5d372004a599d4e3cbb3dda6b32a777 (diff) | |
parent | 8a5121eb8efcd330b518ad0194cd9779a18facf6 (diff) | |
download | gitlab-ce-44cb8a7407d3c9df958328088c914c5bedea284f.tar.gz |
Merge branch 'boards-querystring-backport' into 'master'
don't add trailing = when in urlParamsToArray function
See merge request gitlab-org/gitlab-ce!21179
Diffstat (limited to 'spec/javascripts/lib/utils')
-rw-r--r-- | spec/javascripts/lib/utils/common_utils_spec.js | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/spec/javascripts/lib/utils/common_utils_spec.js b/spec/javascripts/lib/utils/common_utils_spec.js index babad296f09..28151c7e658 100644 --- a/spec/javascripts/lib/utils/common_utils_spec.js +++ b/spec/javascripts/lib/utils/common_utils_spec.js @@ -29,24 +29,46 @@ describe('common_utils', () => { }); }); - describe('getUrlParamsArray', () => { - it('should return params array', () => { - expect(commonUtils.getUrlParamsArray() instanceof Array).toBe(true); + describe('urlParamsToArray', () => { + it('returns empty array for empty querystring', () => { + expect(commonUtils.urlParamsToArray('')).toEqual([]); + }); + + it('should decode params', () => { + expect( + commonUtils.urlParamsToArray('?label_name%5B%5D=test')[0], + ).toBe('label_name[]=test'); }); it('should remove the question mark from the search params', () => { - const paramsArray = commonUtils.getUrlParamsArray(); + const paramsArray = commonUtils.urlParamsToArray('?test=thing'); expect(paramsArray[0][0] !== '?').toBe(true); }); + }); - it('should decode params', () => { - window.history.pushState('', '', '?label_name%5B%5D=test'); + describe('urlParamsToObject', () => { + it('parses path for label with trailing +', () => { + expect( + commonUtils.urlParamsToObject('label_name[]=label%2B', {}), + ).toEqual({ + label_name: ['label+'], + }); + }); + it('parses path for milestone with trailing +', () => { expect( - commonUtils.getUrlParamsArray()[0], - ).toBe('label_name[]=test'); + commonUtils.urlParamsToObject('milestone_title=A%2B', {}), + ).toEqual({ + milestone_title: 'A+', + }); + }); - window.history.pushState('', '', '?'); + it('parses path for search terms with spaces', () => { + expect( + commonUtils.urlParamsToObject('search=two+words', {}), + ).toEqual({ + search: 'two words', + }); }); }); |