From 9e8762f898b9bc424600969b8d25eeb6549fe159 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Thu, 2 Feb 2017 13:20:23 -0600 Subject: rework tests which rely on teaspoon-specific behavior --- spec/javascripts/lib/utils/common_utils_spec.js.es6 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'spec/javascripts/lib/utils') diff --git a/spec/javascripts/lib/utils/common_utils_spec.js.es6 b/spec/javascripts/lib/utils/common_utils_spec.js.es6 index 1ce8f28e568..32c96e2a088 100644 --- a/spec/javascripts/lib/utils/common_utils_spec.js.es6 +++ b/spec/javascripts/lib/utils/common_utils_spec.js.es6 @@ -10,9 +10,9 @@ // IE11 will return a relative pathname while other browsers will return a full pathname. // parseUrl uses an anchor element for parsing an url. With relative urls, the anchor // element will create an absolute url relative to the current execution context. - // The JavaScript test suite is executed at '/teaspoon' which will lead to an absolute - // url starting with '/teaspoon'. - expect(gl.utils.parseUrl('" test="asf"').pathname).toEqual('/teaspoon/%22%20test=%22asf%22'); + // The JavaScript test suite is executed at '/' which will lead to an absolute url + // starting with '/'. + expect(gl.utils.parseUrl('" test="asf"').pathname).toContain('/%22%20test=%22asf%22'); }); }); @@ -42,9 +42,13 @@ }); describe('gl.utils.getParameterByName', () => { + beforeEach(() => { + window.history.pushState({}, null, '?scope=all&p=2'); + }); + it('should return valid parameter', () => { - const value = gl.utils.getParameterByName('reporter'); - expect(value).toBe('Console'); + const value = gl.utils.getParameterByName('scope'); + expect(value).toBe('all'); }); it('should return invalid parameter', () => { -- cgit v1.2.1 From 4428bb27b78bf8f75d8ff15c227a8dfbb82aaa8e Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 1 Feb 2017 15:23:01 +0000 Subject: Removed Masonry, instead uses groups of data Added some error handling which reverts the frontend data changes & notifies the user --- spec/javascripts/lib/utils/text_utility_spec.js.es6 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'spec/javascripts/lib/utils') diff --git a/spec/javascripts/lib/utils/text_utility_spec.js.es6 b/spec/javascripts/lib/utils/text_utility_spec.js.es6 index e97356b65d5..329e18f405a 100644 --- a/spec/javascripts/lib/utils/text_utility_spec.js.es6 +++ b/spec/javascripts/lib/utils/text_utility_spec.js.es6 @@ -21,5 +21,19 @@ expect(largeFont > regular).toBe(true); }); }); + + describe('gl.text.pluralize', () => { + it('returns pluralized', () => { + expect(gl.text.pluralize('test', 2)).toBe('tests'); + }); + + it('returns pluralized', () => { + expect(gl.text.pluralize('test', 0)).toBe('tests'); + }); + + it('does not return pluralized', () => { + expect(gl.text.pluralize('test', 1)).toBe('test'); + }); + }); }); })(); -- cgit v1.2.1 From e85cd9eedef18e2109ca8578380bcc91578b14f3 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 1 Feb 2017 18:42:47 +0000 Subject: Removed duplicated test --- spec/javascripts/lib/utils/text_utility_spec.js.es6 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/javascripts/lib/utils') diff --git a/spec/javascripts/lib/utils/text_utility_spec.js.es6 b/spec/javascripts/lib/utils/text_utility_spec.js.es6 index 329e18f405a..f7d627ceac5 100644 --- a/spec/javascripts/lib/utils/text_utility_spec.js.es6 +++ b/spec/javascripts/lib/utils/text_utility_spec.js.es6 @@ -27,7 +27,7 @@ expect(gl.text.pluralize('test', 2)).toBe('tests'); }); - it('returns pluralized', () => { + it('returns pluralized when count is 0', () => { expect(gl.text.pluralize('test', 0)).toBe('tests'); }); -- cgit v1.2.1