Skip to content

Commit 71275cb

Browse files
committed
COver changes with jasmine test
1 parent 5ad7cbb commit 71275cb

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/url-filter-applier.test.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ define([
1414
filterComponentMock = {
1515
setData: jasmine.createSpy(),
1616
apply: jasmine.createSpy()
17+
},
18+
selectComponentMock = {
19+
options: jasmine.createSpy()
1720
};
1821

1922
beforeEach(function () {
2023
urlFilterApplierObj = new UrlFilterApplier({});
2124
urlFilterApplierObj.filterComponent = jasmine.createSpy().and.returnValue(filterComponentMock);
25+
urlFilterApplierObj.selectComponent = jasmine.createSpy().and.returnValue(selectComponentMock);
2226
});
2327

2428
describe('"getFilterParam" method', function () {
@@ -53,6 +57,21 @@ define([
5357
'qty': '1'
5458
});
5559
});
60+
it('return object from url with multiple options for select filters', function () {
61+
var urlSearch = '?filters[name]=[27,23]&options[]=[value=27,' +
62+
'label=Label]&options[]=[value=23,label=Label2]&filters[qty]=1&anotherparam=1';
63+
64+
expect(urlFilterApplierObj.getOptionsParam(urlSearch)).toEqual([
65+
{
66+
value: '27',
67+
label: 'Label'
68+
},
69+
{
70+
value: '23',
71+
label: 'Label2'
72+
}
73+
]);
74+
});
5675
it('return object from url with another parameter', function () {
5776
var urlSearch = '?anotherparam=1';
5877

@@ -62,12 +81,21 @@ define([
6281

6382
describe('"apply" method', function () {
6483
it('applies url filter on filter component', function () {
65-
urlFilterApplierObj.searchString = '?filters[name]=test&filters[qty]=1';
84+
urlFilterApplierObj.searchString = '?filters[name]=test' +
85+
'&options[]=[value=23,label=Label]&filters[qty]=1';
6686
urlFilterApplierObj.apply();
6787
expect(urlFilterApplierObj.filterComponent().setData).toHaveBeenCalledWith({
6888
'name': 'test',
6989
'qty': '1'
7090
}, false);
91+
expect(urlFilterApplierObj.selectComponent().options).toHaveBeenCalledWith(
92+
[
93+
{
94+
value: '23',
95+
label: 'Label'
96+
}
97+
]
98+
);
7199
expect(urlFilterApplierObj.filterComponent().apply).toHaveBeenCalled();
72100
});
73101
});

0 commit comments

Comments
 (0)