Add tests for new common_utils functions
This commit is contained in:
parent
cf391760f1
commit
3cb156dd45
1 changed files with 25 additions and 0 deletions
|
@ -15,6 +15,7 @@
|
|||
expect(gl.utils.parseUrl('" test="asf"').pathname).toEqual('/teaspoon/%22%20test=%22asf%22');
|
||||
});
|
||||
});
|
||||
|
||||
describe('gl.utils.parseUrlPathname', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(gl.utils, 'parseUrl').and.callFake(url => ({
|
||||
|
@ -28,5 +29,29 @@
|
|||
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);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
})();
|
||||
|
|
Loading…
Reference in a new issue