diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-21 09:10:16 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-21 09:10:16 +0000 |
commit | 34ad6d995bcab9f88a236bfed15aebdad76df960 (patch) | |
tree | 4e47f30ed36fbdebd15933b10a04b80ae98f0475 /spec/frontend/lib/utils/url_utility_spec.js | |
parent | 1cf90c700837637f7989bda8fe81c616f19e8150 (diff) | |
download | gitlab-ce-34ad6d995bcab9f88a236bfed15aebdad76df960.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/lib/utils/url_utility_spec.js')
-rw-r--r-- | spec/frontend/lib/utils/url_utility_spec.js | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/spec/frontend/lib/utils/url_utility_spec.js b/spec/frontend/lib/utils/url_utility_spec.js index e12cd8b0e37..8a04e93e88c 100644 --- a/spec/frontend/lib/utils/url_utility_spec.js +++ b/spec/frontend/lib/utils/url_utility_spec.js @@ -798,15 +798,29 @@ describe('URL utility', () => { ); }); - it('handles arrays properly', () => { + it('adds parameters from arrays', () => { const url = 'https://gitlab.com/test'; - expect(urlUtils.setUrlParams({ label_name: ['foo', 'bar'] }, url)).toEqual( - 'https://gitlab.com/test?label_name=foo&label_name=bar', + expect(urlUtils.setUrlParams({ labels: ['foo', 'bar'] }, url)).toEqual( + 'https://gitlab.com/test?labels=foo&labels=bar', ); }); - it('handles arrays properly when railsArraySyntax=true', () => { + it('removes parameters from empty arrays', () => { + const url = 'https://gitlab.com/test?labels=foo&labels=bar'; + + expect(urlUtils.setUrlParams({ labels: [] }, url)).toEqual('https://gitlab.com/test'); + }); + + it('removes parameters from empty arrays while keeping other parameters', () => { + const url = 'https://gitlab.com/test?labels=foo&labels=bar&unrelated=unrelated'; + + expect(urlUtils.setUrlParams({ labels: [] }, url)).toEqual( + 'https://gitlab.com/test?unrelated=unrelated', + ); + }); + + it('adds parameters from arrays when railsArraySyntax=true', () => { const url = 'https://gitlab.com/test'; expect(urlUtils.setUrlParams({ labels: ['foo', 'bar'] }, url, false, true)).toEqual( @@ -814,6 +828,14 @@ describe('URL utility', () => { ); }); + it('removes parameters from empty arrays when railsArraySyntax=true', () => { + const url = 'https://gitlab.com/test?labels%5B%5D=foo&labels%5B%5D=bar'; + + expect(urlUtils.setUrlParams({ labels: [] }, url, false, true)).toEqual( + 'https://gitlab.com/test', + ); + }); + it('decodes URI when decodeURI=true', () => { const url = 'https://gitlab.com/test'; |