File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -229,7 +229,9 @@ function normalizeDate(date, isDateStart) {
229
229
}
230
230
231
231
function validate_filters ( _values , _default ) {
232
- return Object . assign ( _values , _default )
232
+ return {
233
+ ..._default , ..._values
234
+ }
233
235
}
234
236
235
237
exports = module . exports = {
Original file line number Diff line number Diff line change @@ -31,12 +31,24 @@ describe('QueryString: Filters', function () {
31
31
} )
32
32
} )
33
33
34
- context ( 'when use the default options without query ' , function ( ) {
34
+ context ( 'when use the default options' , function ( ) {
35
35
it ( 'should return a JSON with default filters params' , function ( done ) {
36
36
const result = filter . filters ( { } , default_options )
37
37
expect ( result ) . to . eql ( default_options . default . filters )
38
38
done ( )
39
39
} )
40
+
41
+ it ( 'should return a JSON with default filters params and those of the query' , function ( done ) {
42
+ const options = {
43
+ ...default_options , ...{
44
+ default : { filters : { age : '19' , name : 'John' } }
45
+ }
46
+ }
47
+ const result = filter . filters ( { age : '21' } , options )
48
+ expect ( result . name ) . to . eql ( options . default . filters . name )
49
+ expect ( result . age ) . to . eql ( 21 )
50
+ done ( )
51
+ } )
40
52
} )
41
53
} )
42
54
@@ -45,4 +57,4 @@ function verify(result) {
45
57
expect ( result ) . to . have . property ( 'age' )
46
58
expect ( result . name ) . to . eql ( 'lucas' )
47
59
expect ( result . age ) . to . eql ( 30 )
48
- }
60
+ }
You can’t perform that action at this time.
0 commit comments