Skip to content

Commit d451b58

Browse files
committed
MAGETWO-87815: Update PAT scenarios for caching popular search terms functionality
1 parent 398ebd4 commit d451b58

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

dev/tests/js/jasmine/tests/lib/mage/misc.test.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,37 @@ define([
1212
describe('mageUtils', function () {
1313

1414
it('Check getUrlParameters function', function () {
15-
var url = 'http://example.com/catalogsearch/result/?q=+Simple+99%2C+8%2F%3F&cat=3',
16-
urlParameters = {
15+
var fixture,
16+
url,
17+
getParameters;
18+
19+
fixture = {
20+
'not valid url' : {},
21+
'http://example.com/catalogsearch/result/' : {},
22+
'http://example.com/catalogsearch/result/?' : {},
23+
'http://example.com/catalogsearch/result/?q' : {
24+
q: ''
25+
},
26+
'http://example.com/catalogsearch/result/?q=' : {
27+
q: ''
28+
},
29+
'http://example.com/catalogsearch/result/?q=+Simple+99%2C+8%2F%3F&cat=3' : {
1730
q: ' Simple 99, 8/?',
1831
cat: '3'
19-
};
32+
},
33+
'http://example.com/catalogsearch/result/?q=Simple&cat=3&p=1' : {
34+
q: 'Simple',
35+
cat: '3',
36+
p: '1'
37+
}
38+
};
2039

21-
expect(utils.getUrlParameters(url)).toEqual(urlParameters);
40+
for (url in fixture) {
41+
if (fixture.hasOwnProperty(url)) {
42+
getParameters = fixture[url];
43+
expect(utils.getUrlParameters(url)).toEqual(getParameters);
44+
}
45+
}
2246
});
2347

2448
it('Check convertToMomentFormat function', function () {

lib/web/mage/utils/misc.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,14 @@ define([
272272

273273
if (queries[1]) {
274274
queries = queries[1].split('&');
275+
275276
for (i = 0, l = queries.length; i < l; i++) {
276277
temp = queries[i].split('=');
277-
params[temp[0]] = decodeURIComponent(temp[1].replace(/\+/g, '%20'));
278+
if (temp[1]) {
279+
params[temp[0]] = decodeURIComponent(temp[1].replace(/\+/g, '%20'));
280+
} else {
281+
params[temp[0]] = '';
282+
}
278283
}
279284
}
280285

0 commit comments

Comments
 (0)