Commit 67270875 authored by Martin Wortschack's avatar Martin Wortschack

Merge branch 'fe-move-seturlparams-describe' into 'master'

Move setUrlParams describe under top describe

See merge request gitlab-org/gitlab!21904
parents 90de22f7 83fc82f8
...@@ -330,46 +330,46 @@ describe('URL utility', () => { ...@@ -330,46 +330,46 @@ describe('URL utility', () => {
expect(urlUtils.escapeFileUrl('foo/bar/file.md')).toBe('foo/bar/file.md'); expect(urlUtils.escapeFileUrl('foo/bar/file.md')).toBe('foo/bar/file.md');
}); });
}); });
});
describe('setUrlParams', () => { describe('setUrlParams', () => {
it('adds new params as query string', () => { it('adds new params as query string', () => {
const url = 'https://gitlab.com/test'; const url = 'https://gitlab.com/test';
expect( expect(
urlUtils.setUrlParams({ group_id: 'gitlab-org', project_id: 'my-project' }, url), urlUtils.setUrlParams({ group_id: 'gitlab-org', project_id: 'my-project' }, url),
).toEqual('https://gitlab.com/test?group_id=gitlab-org&project_id=my-project'); ).toEqual('https://gitlab.com/test?group_id=gitlab-org&project_id=my-project');
}); });
it('updates an existing parameter', () => { it('updates an existing parameter', () => {
const url = 'https://gitlab.com/test?group_id=gitlab-org&project_id=my-project'; const url = 'https://gitlab.com/test?group_id=gitlab-org&project_id=my-project';
expect(urlUtils.setUrlParams({ project_id: 'gitlab-test' }, url)).toEqual( expect(urlUtils.setUrlParams({ project_id: 'gitlab-test' }, url)).toEqual(
'https://gitlab.com/test?group_id=gitlab-org&project_id=gitlab-test', 'https://gitlab.com/test?group_id=gitlab-org&project_id=gitlab-test',
); );
}); });
it("removes the project_id param when it's value is null", () => { 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'; const url = 'https://gitlab.com/test?group_id=gitlab-org&project_id=my-project';
expect(urlUtils.setUrlParams({ project_id: null }, url)).toEqual( expect(urlUtils.setUrlParams({ project_id: null }, url)).toEqual(
'https://gitlab.com/test?group_id=gitlab-org', 'https://gitlab.com/test?group_id=gitlab-org',
); );
}); });
it('handles arrays properly', () => { it('handles arrays properly', () => {
const url = 'https://gitlab.com/test'; const url = 'https://gitlab.com/test';
expect(urlUtils.setUrlParams({ label_name: ['foo', 'bar'] }, url)).toEqual( expect(urlUtils.setUrlParams({ label_name: ['foo', 'bar'] }, url)).toEqual(
'https://gitlab.com/test?label_name=foo&label_name=bar', 'https://gitlab.com/test?label_name=foo&label_name=bar',
); );
}); });
it('removes all existing URL params and sets a new param when cleanParams=true', () => { 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'; const url = 'https://gitlab.com/test?group_id=gitlab-org&project_id=my-project';
expect(urlUtils.setUrlParams({ foo: 'bar' }, url, true)).toEqual( expect(urlUtils.setUrlParams({ foo: 'bar' }, url, true)).toEqual(
'https://gitlab.com/test?foo=bar', 'https://gitlab.com/test?foo=bar',
); );
});
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment