@@ -14,11 +14,15 @@ define([
14
14
filterComponentMock = {
15
15
setData : jasmine . createSpy ( ) ,
16
16
apply : jasmine . createSpy ( )
17
+ } ,
18
+ selectComponentMock = {
19
+ options : jasmine . createSpy ( )
17
20
} ;
18
21
19
22
beforeEach ( function ( ) {
20
23
urlFilterApplierObj = new UrlFilterApplier ( { } ) ;
21
24
urlFilterApplierObj . filterComponent = jasmine . createSpy ( ) . and . returnValue ( filterComponentMock ) ;
25
+ urlFilterApplierObj . selectComponent = jasmine . createSpy ( ) . and . returnValue ( selectComponentMock ) ;
22
26
} ) ;
23
27
24
28
describe ( '"getFilterParam" method' , function ( ) {
@@ -53,6 +57,21 @@ define([
53
57
'qty' : '1'
54
58
} ) ;
55
59
} ) ;
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
+ } ) ;
56
75
it ( 'return object from url with another parameter' , function ( ) {
57
76
var urlSearch = '?anotherparam=1' ;
58
77
@@ -62,12 +81,21 @@ define([
62
81
63
82
describe ( '"apply" method' , function ( ) {
64
83
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' ;
66
86
urlFilterApplierObj . apply ( ) ;
67
87
expect ( urlFilterApplierObj . filterComponent ( ) . setData ) . toHaveBeenCalledWith ( {
68
88
'name' : 'test' ,
69
89
'qty' : '1'
70
90
} , false ) ;
91
+ expect ( urlFilterApplierObj . selectComponent ( ) . options ) . toHaveBeenCalledWith (
92
+ [
93
+ {
94
+ value : '23' ,
95
+ label : 'Label'
96
+ }
97
+ ]
98
+ ) ;
71
99
expect ( urlFilterApplierObj . filterComponent ( ) . apply ) . toHaveBeenCalled ( ) ;
72
100
} ) ;
73
101
} ) ;
0 commit comments