diff options
author | Scott Escue <scott.escue@gmail.com> | 2018-11-27 16:16:24 +0300 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2019-01-10 09:00:39 +0300 |
commit | 2cbc475e5327a860032414561916c7bd725685ac (patch) | |
tree | abf5ca4adc9c2e2d3bc329dafe9aed1b37f35043 /spec/javascripts/lib | |
parent | a3541a8d8dd1f4db690b7293d2a7674287020e84 (diff) |
Fixing static analysis issues
Diffstat (limited to 'spec/javascripts/lib')
-rw-r--r-- | spec/javascripts/lib/utils/url_utility_spec.js | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/spec/javascripts/lib/utils/url_utility_spec.js b/spec/javascripts/lib/utils/url_utility_spec.js index fe787baf08e..1ac1c414df7 100644 --- a/spec/javascripts/lib/utils/url_utility_spec.js +++ b/spec/javascripts/lib/utils/url_utility_spec.js @@ -32,8 +32,13 @@ describe('URL utility', () => { expect(urlUtils.mergeUrlParams({ w: 1 }, '#frag')).toBe('?w=1#frag'); expect(urlUtils.mergeUrlParams({ w: 1 }, '/path#frag')).toBe('/path?w=1#frag'); expect(urlUtils.mergeUrlParams({ w: 1 }, 'https://host/path')).toBe('https://host/path?w=1'); - expect(urlUtils.mergeUrlParams({ w: 1 }, 'https://host/path#frag')).toBe('https://host/path?w=1#frag'); - expect(urlUtils.mergeUrlParams({ w: 1 }, 'https://h/p?k1=v1#frag')).toBe('https://h/p?k1=v1&w=1#frag'); + expect(urlUtils.mergeUrlParams({ w: 1 }, 'https://host/path#frag')).toBe( + 'https://host/path?w=1#frag', + ); + + expect(urlUtils.mergeUrlParams({ w: 1 }, 'https://h/p?k1=v1#frag')).toBe( + 'https://h/p?k1=v1&w=1#frag', + ); }); it('updates w', () => { @@ -59,21 +64,25 @@ describe('URL utility', () => { it('should remove param when url has no other params', () => { const url = urlUtils.removeParams(['size'], '/feature/home?size=5'); + expect(url).toBe('/feature/home'); }); it('should remove param when url has other params', () => { const url = urlUtils.removeParams(['size'], '/feature/home?q=1&size=5&f=html'); + expect(url).toBe('/feature/home?q=1&f=html'); }); it('should remove param and preserve fragment', () => { const url = urlUtils.removeParams(['size'], '/feature/home?size=5#H2'); + expect(url).toBe('/feature/home#H2'); }); it('should remove multiple params', () => { const url = urlUtils.removeParams(['z', 'a'], '/home?z=11111&l=en_US&a=true#H2'); + expect(url).toBe('/home?l=en_US#H2'); }); }); @@ -87,6 +96,7 @@ describe('URL utility', () => { }); const url = urlUtils.removeParams(['locale']); + expect(url).toBe('https://mysite.com/?zip=11111&ads=false#privacy'); }); }); @@ -95,16 +105,19 @@ describe('URL utility', () => { describe('setUrlFragment', () => { it('should set fragment when url has no fragment', () => { const url = urlUtils.setUrlFragment('/home/feature', 'usage'); + expect(url).toBe('/home/feature#usage'); }); it('should set fragment when url has existing fragment', () => { const url = urlUtils.setUrlFragment('/home/feature#overview', 'usage'); + expect(url).toBe('/home/feature#usage'); }); it('should set fragment when given fragment includes #', () => { const url = urlUtils.setUrlFragment('/home/feature#overview', '#install'); + expect(url).toBe('/home/feature#install'); }); }); |