summaryrefslogtreecommitdiff
path: root/spec/frontend
diff options
context:
space:
mode:
authorSimon Knox <simon@gitlab.com>2019-08-08 00:06:45 +0000
committerMike Greiling <mike@pixelcog.com>2019-08-08 00:06:45 +0000
commit055a7b973dd99185f2dee01a3d4774f9f0a5e1b6 (patch)
tree61c1032a084b9b996a9fa639bad263ea784b76c8 /spec/frontend
parenteec1ed522d4103ee7d347c305f1021db33173def (diff)
downloadgitlab-ce-055a7b973dd99185f2dee01a3d4774f9f0a5e1b6.tar.gz
Simplify getTimeDiff function
Pass keyname instead of translated string
Diffstat (limited to 'spec/frontend')
-rw-r--r--spec/frontend/lib/utils/url_utility_spec.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/frontend/lib/utils/url_utility_spec.js b/spec/frontend/lib/utils/url_utility_spec.js
index c771984a137..a986bc49f28 100644
--- a/spec/frontend/lib/utils/url_utility_spec.js
+++ b/spec/frontend/lib/utils/url_utility_spec.js
@@ -34,6 +34,41 @@ describe('URL utility', () => {
});
});
+ describe('getParameterValues', () => {
+ beforeEach(() => {
+ setWindowLocation({
+ href: 'https://gitlab.com?test=passing&multiple=1&multiple=2',
+ // make our fake location act like real window.location.toString
+ // URL() (used in getParameterValues) does this if passed an object
+ toString() {
+ return this.href;
+ },
+ });
+ });
+
+ it('returns empty array for no params', () => {
+ expect(urlUtils.getParameterValues()).toEqual([]);
+ });
+
+ it('returns empty array for non-matching params', () => {
+ expect(urlUtils.getParameterValues('notFound')).toEqual([]);
+ });
+
+ it('returns single match', () => {
+ expect(urlUtils.getParameterValues('test')).toEqual(['passing']);
+ });
+
+ it('returns multiple matches', () => {
+ expect(urlUtils.getParameterValues('multiple')).toEqual(['1', '2']);
+ });
+
+ it('accepts url as second arg', () => {
+ const url = 'https://gitlab.com?everything=works';
+ expect(urlUtils.getParameterValues('everything', url)).toEqual(['works']);
+ expect(urlUtils.getParameterValues('test', url)).toEqual([]);
+ });
+ });
+
describe('mergeUrlParams', () => {
it('adds w', () => {
expect(urlUtils.mergeUrlParams({ w: 1 }, '#frag')).toBe('?w=1#frag');