Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-13 15:07:41 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-13 15:07:41 +0300
commit8cc5f2790908ba9bb8eecba2b78a3c5a88c77b90 (patch)
tree2d6211503a5111d43a9edce0c56b94fd1b347e1b /spec/frontend/lib
parent17b91a3c6ab73fff087e91665e9afb8046cbf045 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/lib')
-rw-r--r--spec/frontend/lib/utils/url_utility_spec.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/frontend/lib/utils/url_utility_spec.js b/spec/frontend/lib/utils/url_utility_spec.js
index 97f7f05cd85..0e818d6c402 100644
--- a/spec/frontend/lib/utils/url_utility_spec.js
+++ b/spec/frontend/lib/utils/url_utility_spec.js
@@ -323,3 +323,45 @@ describe('URL utility', () => {
});
});
});
+
+describe('setUrlParams', () => {
+ it('adds new params as query string', () => {
+ const url = 'https://gitlab.com/test';
+
+ expect(
+ urlUtils.setUrlParams({ group_id: 'gitlab-org', project_id: 'my-project' }, url),
+ ).toEqual('https://gitlab.com/test?group_id=gitlab-org&project_id=my-project');
+ });
+
+ it('updates an existing parameter', () => {
+ const url = 'https://gitlab.com/test?group_id=gitlab-org&project_id=my-project';
+
+ expect(urlUtils.setUrlParams({ project_id: 'gitlab-test' }, url)).toEqual(
+ 'https://gitlab.com/test?group_id=gitlab-org&project_id=gitlab-test',
+ );
+ });
+
+ it("removes the project_id param when it's value is null", () => {
+ const url = 'https://gitlab.com/test?group_id=gitlab-org&project_id=my-project';
+
+ expect(urlUtils.setUrlParams({ project_id: null }, url)).toEqual(
+ 'https://gitlab.com/test?group_id=gitlab-org',
+ );
+ });
+
+ it('handles arrays properly', () => {
+ 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',
+ );
+ });
+
+ it('removes all existing URL params and sets a new param when cleanParams=true', () => {
+ const url = 'https://gitlab.com/test?group_id=gitlab-org&project_id=my-project';
+
+ expect(urlUtils.setUrlParams({ foo: 'bar' }, url, true)).toEqual(
+ 'https://gitlab.com/test?foo=bar',
+ );
+ });
+});