|
|
@@ -91,3 +91,30 @@ describe('split', () => {
|
|
|
expect(UrlUtils.split('')).toEqual([])
|
|
|
})
|
|
|
})
|
|
|
+
|
|
|
+describe('addQuery', () => {
|
|
|
+ test('with empty query', () => {
|
|
|
+ expect(UrlUtils.addQuery('foo/bar', {})).toEqual('/foo/bar')
|
|
|
+ })
|
|
|
+ test('with simple query', () => {
|
|
|
+ expect(UrlUtils.addQuery('foo/bar', {'a': 1})).toEqual('/foo/bar?a=1')
|
|
|
+ })
|
|
|
+ test('with longer query', () => {
|
|
|
+ expect(UrlUtils.addQuery('foo/bar', {'a': 1, 'b': 2})).toEqual('/foo/bar?a=1&b=2')
|
|
|
+ })
|
|
|
+ test('with existing query', () => {
|
|
|
+ expect(UrlUtils.addQuery('foo/bar?a=1', {'b': 2})).toEqual('/foo/bar?a=1&b=2')
|
|
|
+ })
|
|
|
+ test('with empty url', () => {
|
|
|
+ expect(UrlUtils.addQuery('', {'a': 1})).toEqual('/?a=1')
|
|
|
+ })
|
|
|
+ test('with empty url and empty query', () => {
|
|
|
+ expect(UrlUtils.addQuery('', {})).toEqual('/')
|
|
|
+ })
|
|
|
+ test('with absolute url', () => {
|
|
|
+ expect(UrlUtils.addQuery('https://foo.com/bar/', {'a': 1})).toEqual('https://foo.com/bar/?a=1')
|
|
|
+ })
|
|
|
+ test('with number sign in path name', () => {
|
|
|
+ expect(UrlUtils.addQuery('https://foo.com/#/bar/', {'a': 1})).toEqual('https://foo.com/#/bar/?a=1')
|
|
|
+ })
|
|
|
+})
|