diff options
author | Phil Hughes <me@iamphill.com> | 2017-01-13 10:30:40 -0500 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-01-13 10:30:40 -0500 |
commit | 639bca436297e65f16499c5b76a9e5ffb2b798c8 (patch) | |
tree | 832636f41824529da2796dedc7888effd42940c9 /spec/javascripts/lib | |
parent | bdcb81be95b3287e14cf23b2f1d0849b24077360 (diff) | |
parent | 4b43126d08972c201551fbd1fe42e85847d5e03f (diff) | |
download | gitlab-ce-639bca436297e65f16499c5b76a9e5ffb2b798c8.tar.gz |
Merge branch 'master' into go-go-gadget-webpack
Diffstat (limited to 'spec/javascripts/lib')
-rw-r--r-- | spec/javascripts/lib/utils/common_utils_spec.js.es6 | 24 | ||||
-rw-r--r-- | spec/javascripts/lib/utils/text_utility_spec.js.es6 | 25 |
2 files changed, 49 insertions, 0 deletions
diff --git a/spec/javascripts/lib/utils/common_utils_spec.js.es6 b/spec/javascripts/lib/utils/common_utils_spec.js.es6 index e33360a1875..a54bb9bb444 100644 --- a/spec/javascripts/lib/utils/common_utils_spec.js.es6 +++ b/spec/javascripts/lib/utils/common_utils_spec.js.es6 @@ -15,6 +15,7 @@ require('~/lib/utils/common_utils'); expect(gl.utils.parseUrl('" test="asf"').pathname).toEqual('/%22%20test=%22asf%22'); }); }); + describe('gl.utils.parseUrlPathname', () => { beforeEach(() => { spyOn(gl.utils, 'parseUrl').and.callFake(url => ({ @@ -28,5 +29,28 @@ require('~/lib/utils/common_utils'); expect(gl.utils.parseUrlPathname('some/relative/url')).toEqual('/some/relative/url'); }); }); + + describe('gl.utils.getUrlParamsArray', () => { + it('should return params array', () => { + expect(gl.utils.getUrlParamsArray() instanceof Array).toBe(true); + }); + + it('should remove the question mark from the search params', () => { + const paramsArray = gl.utils.getUrlParamsArray(); + expect(paramsArray[0][0] !== '?').toBe(true); + }); + }); + + describe('gl.utils.getParameterByName', () => { + it('should return valid parameter', () => { + const value = gl.utils.getParameterByName('reporter'); + expect(value).toBe('Console'); + }); + + it('should return invalid parameter', () => { + const value = gl.utils.getParameterByName('fakeParameter'); + expect(value).toBe(null); + }); + }); }); })(); diff --git a/spec/javascripts/lib/utils/text_utility_spec.js.es6 b/spec/javascripts/lib/utils/text_utility_spec.js.es6 new file mode 100644 index 00000000000..e97356b65d5 --- /dev/null +++ b/spec/javascripts/lib/utils/text_utility_spec.js.es6 @@ -0,0 +1,25 @@ +//= require lib/utils/text_utility + +(() => { + describe('text_utility', () => { + describe('gl.text.getTextWidth', () => { + it('returns zero width when no text is passed', () => { + expect(gl.text.getTextWidth('')).toBe(0); + }); + + it('returns zero width when no text is passed and font is passed', () => { + expect(gl.text.getTextWidth('', '100px sans-serif')).toBe(0); + }); + + it('returns width when text is passed', () => { + expect(gl.text.getTextWidth('foo') > 0).toBe(true); + }); + + it('returns bigger width when font is larger', () => { + const largeFont = gl.text.getTextWidth('foo', '100px sans-serif'); + const regular = gl.text.getTextWidth('foo', '10px sans-serif'); + expect(largeFont > regular).toBe(true); + }); + }); + }); +})(); |