@@ -42,7 +42,7 @@ describe('queryFilter()', function () {
42
42
43
43
context ( 'when query contains pagination param with string limit as skip' , function ( ) {
44
44
it ( 'should return req.query with set pagination params' , function ( ) {
45
- const expect_pagination = { limit : Number . MAX_SAFE_INTEGER , skip : 2 }
45
+ const expect_pagination = { limit : Number . MAX_SAFE_INTEGER , skip : 2 }
46
46
47
47
const options = JSON . parse ( JSON . stringify ( default_options ) )
48
48
options . default . pagination . limit = expect_pagination . limit
@@ -60,7 +60,7 @@ describe('queryFilter()', function () {
60
60
61
61
context ( 'when query contains pagination param with string skip' , function ( ) {
62
62
it ( 'should return req.query with set pagination params' , function ( ) {
63
- const expect_pagination = { limit : 10 , skip : 0 }
63
+ const expect_pagination = { limit : 10 , skip : 0 }
64
64
65
65
const options = JSON . parse ( JSON . stringify ( default_options ) )
66
66
options . default . pagination . limit = expect_pagination . limit
@@ -78,7 +78,7 @@ describe('queryFilter()', function () {
78
78
79
79
context ( 'when query contains ordination param' , function ( ) {
80
80
it ( 'should return req.query with set ordination params' , function ( ) {
81
- const expect_sort = { name : 1 , age : - 1 }
81
+ const expect_sort = { name : 1 , age : - 1 }
82
82
83
83
const options = JSON . parse ( JSON . stringify ( default_options ) )
84
84
options . default . sort = expect_sort
@@ -95,7 +95,7 @@ describe('queryFilter()', function () {
95
95
96
96
context ( 'when query contains fields param' , function ( ) {
97
97
it ( 'should return req.query with set field params' , function ( ) {
98
- const expect_fields = { name : 1 , age : 1 }
98
+ const expect_fields = { name : 1 , age : 1 }
99
99
100
100
const options = JSON . parse ( JSON . stringify ( default_options ) )
101
101
options . default . fields = expect_fields
@@ -112,7 +112,7 @@ describe('queryFilter()', function () {
112
112
113
113
context ( 'when query contains simple filters param' , function ( ) {
114
114
it ( 'should return req.query with set field params' , function ( ) {
115
- const expect_filters = { name : 'lucas' , age : 30 }
115
+ const expect_filters = { name : 'lucas' , age : 30 }
116
116
117
117
const options = JSON . parse ( JSON . stringify ( default_options ) )
118
118
options . default . filters = expect_filters
@@ -138,17 +138,17 @@ describe('queryFilter()', function () {
138
138
name : { '$options' : 'i' , '$regex' : 'd[o,ó,ö,ò,ô][u,ü,ú,ù]gl[a,á,à,ä,â,ã]s$' }
139
139
} ,
140
140
{
141
- name : { '$options' : 'i' , '$regex' : 'j[o,ó,ö,ò,ô]rg[e,é,ë,ê ]' }
141
+ name : { '$options' : 'i' , '$regex' : 'J[O,Ó,Ö,Ò,Ô]RG[E,É,Ë,Ê ]' }
142
142
} ] ,
143
143
'school.name' : 'UEPB' ,
144
144
'timestamp' : '2018-12-05T00:00:00' ,
145
- '$or' : [ { job : 'Developer' } , { job : 'Engineer' } ]
145
+ '$or' : [ { job : 'Developer' } , { job : 'Engineer' } ]
146
146
}
147
147
148
148
const options = JSON . parse ( JSON . stringify ( default_options ) )
149
149
options . default . filters = expect_filters
150
150
151
- const query = '?name=lucas****&name=*****douglas&name=*****jorge *****&.school.name.=UEPB'
151
+ const query = '?name=lucas****&name=*****douglas&name=*****JORGE *****&.school.name.=UEPB'
152
152
. concat ( '×tamp=2018-12-05&job=Developer,Engineer' )
153
153
154
154
return request ( app )
@@ -163,9 +163,9 @@ describe('queryFilter()', function () {
163
163
it ( 'should return req.query with set field params' , function ( ) {
164
164
const expect_filters = {
165
165
name : 'lucas' ,
166
- age : { $gt : 30 } ,
167
- timestamp : { $gt : '2018-12-05T00:00:00' } ,
168
- created_at : { $lte : '2018-12-06T00:00:00' } ,
166
+ age : { $gt : 30 } ,
167
+ timestamp : { $gt : '2018-12-05T00:00:00' } ,
168
+ created_at : { $lte : '2018-12-06T00:00:00' } ,
169
169
sleep_hour : '22:40'
170
170
}
171
171
@@ -185,10 +185,10 @@ describe('queryFilter()', function () {
185
185
it ( 'should return req.query with set field params (with $ne filter)' , function ( ) {
186
186
const expect_filters = {
187
187
name : 'lucas' ,
188
- age : { $gt : 30 } ,
189
- type : { $ne : 'admin' } ,
190
- timestamp : { $gt : '2018-12-05T00:00:00' } ,
191
- created_at : { $lte : '2018-12-06T00:00:00' } ,
188
+ age : { $gt : 30 } ,
189
+ type : { $ne : 'admin' } ,
190
+ timestamp : { $gt : '2018-12-05T00:00:00' } ,
191
+ created_at : { $lte : '2018-12-06T00:00:00' } ,
192
192
sleep_hour : '22:40'
193
193
}
194
194
@@ -210,8 +210,8 @@ describe('queryFilter()', function () {
210
210
it ( 'should return req.query with set start_at params as today' , function ( ) {
211
211
const expect_filters = {
212
212
$and : [
213
- { created_at : { $lt : normalizeDate ( dateToString ( new Date ( ) ) , false ) } } ,
214
- { created_at : { $gte : normalizeDate ( dateToString ( new Date ( ) ) , true ) } }
213
+ { created_at : { $lt : normalizeDate ( dateToString ( new Date ( ) ) , false ) } } ,
214
+ { created_at : { $gte : normalizeDate ( dateToString ( new Date ( ) ) , true ) } }
215
215
]
216
216
}
217
217
@@ -230,8 +230,8 @@ describe('queryFilter()', function () {
230
230
it ( 'should return req.query with set end_at params as today' , function ( ) {
231
231
const expect_filters = {
232
232
$and : [
233
- { created_at : { $lt : normalizeDate ( dateToString ( new Date ( ) ) , false ) } } ,
234
- { created_at : { $gte : '2019-02-05T00:00:00' } }
233
+ { created_at : { $lt : normalizeDate ( dateToString ( new Date ( ) ) , false ) } } ,
234
+ { created_at : { $gte : '2019-02-05T00:00:00' } }
235
235
]
236
236
}
237
237
@@ -250,8 +250,8 @@ describe('queryFilter()', function () {
250
250
it ( 'should return req.query with set start_at params as date' , function ( ) {
251
251
const expect_filters = {
252
252
$and : [
253
- { created_at : { $lt : normalizeDate ( dateToString ( new Date ( ) ) , false ) } } ,
254
- { created_at : { $gte : '2018-12-05T00:00:01' } }
253
+ { created_at : { $lt : normalizeDate ( dateToString ( new Date ( ) ) , false ) } } ,
254
+ { created_at : { $gte : '2018-12-05T00:00:01' } }
255
255
]
256
256
}
257
257
@@ -271,8 +271,8 @@ describe('queryFilter()', function () {
271
271
it ( 'should return req.query with set start_at params as dateTime' , function ( ) {
272
272
const expect_filters = {
273
273
$and : [
274
- { created_at : { $lt : normalizeDate ( dateToString ( new Date ( ) ) , false ) } } ,
275
- { created_at : { $gte : '2018-12-05T00:00:00' } }
274
+ { created_at : { $lt : normalizeDate ( dateToString ( new Date ( ) ) , false ) } } ,
275
+ { created_at : { $gte : '2018-12-05T00:00:00' } }
276
276
]
277
277
}
278
278
@@ -292,8 +292,8 @@ describe('queryFilter()', function () {
292
292
293
293
const expect_filters = {
294
294
$and : [
295
- { created_at : { $lt : '2018-12-11T00:00:00' } } ,
296
- { created_at : { $gte : '2018-12-01T00:00:00' } } ]
295
+ { created_at : { $lt : '2018-12-11T00:00:00' } } ,
296
+ { created_at : { $gte : '2018-12-01T00:00:00' } } ]
297
297
}
298
298
299
299
@@ -313,8 +313,8 @@ describe('queryFilter()', function () {
313
313
314
314
const expect_filters = {
315
315
$and : [
316
- { created_at : { $lt : '2018-12-11T03:02:01' } } ,
317
- { created_at : { $gte : '2018-12-01T01:02:03' } } ]
316
+ { created_at : { $lt : '2018-12-11T03:02:01' } } ,
317
+ { created_at : { $gte : '2018-12-01T01:02:03' } } ]
318
318
}
319
319
320
320
const options = JSON . parse ( JSON . stringify ( default_options ) )
@@ -332,8 +332,8 @@ describe('queryFilter()', function () {
332
332
it ( 'should return req.query with period as day and start_at param' , function ( ) {
333
333
const expect_filters = {
334
334
$and : [
335
- { created_at : { $lt : '2019-01-26T23:59:59' } } ,
336
- { created_at : { $gte : '2019-01-24T00:00:00' } }
335
+ { created_at : { $lt : '2019-01-26T23:59:59' } } ,
336
+ { created_at : { $gte : '2019-01-24T00:00:00' } }
337
337
]
338
338
}
339
339
@@ -352,8 +352,8 @@ describe('queryFilter()', function () {
352
352
it ( 'should return req.query with period as day and end_at param' , function ( ) {
353
353
const expect_filters = {
354
354
$and : [
355
- { created_at : { $lt : '2019-01-26T00:00:00' } } ,
356
- { created_at : { $gte : '2019-01-24T00:00:00' } }
355
+ { created_at : { $lt : '2019-01-26T00:00:00' } } ,
356
+ { created_at : { $gte : '2019-01-24T00:00:00' } }
357
357
]
358
358
}
359
359
@@ -372,8 +372,8 @@ describe('queryFilter()', function () {
372
372
it ( 'should return req.query with period as week and start_at param' , function ( ) {
373
373
const expect_filters = {
374
374
$and : [
375
- { created_at : { $lt : '2019-01-26T23:59:59' } } ,
376
- { created_at : { $gte : '2019-01-19T00:00:00' } }
375
+ { created_at : { $lt : '2019-01-26T23:59:59' } } ,
376
+ { created_at : { $gte : '2019-01-19T00:00:00' } }
377
377
]
378
378
}
379
379
@@ -392,8 +392,8 @@ describe('queryFilter()', function () {
392
392
it ( 'should return req.query with period as week and end_at param' , function ( ) {
393
393
const expect_filters = {
394
394
$and : [
395
- { created_at : { $lt : '2019-01-26T23:59:59' } } ,
396
- { created_at : { $gte : '2019-01-19T00:00:00' } }
395
+ { created_at : { $lt : '2019-01-26T23:59:59' } } ,
396
+ { created_at : { $gte : '2019-01-19T00:00:00' } }
397
397
]
398
398
}
399
399
@@ -412,8 +412,8 @@ describe('queryFilter()', function () {
412
412
it ( 'should return req.query with period as month and start_at param' , function ( ) {
413
413
const expect_filters = {
414
414
$and : [
415
- { created_at : { $lt : '2019-02-24T23:59:59' } } ,
416
- { created_at : { $gte : '2019-01-24T00:00:00' } }
415
+ { created_at : { $lt : '2019-02-24T23:59:59' } } ,
416
+ { created_at : { $gte : '2019-01-24T00:00:00' } }
417
417
]
418
418
}
419
419
@@ -432,8 +432,8 @@ describe('queryFilter()', function () {
432
432
it ( 'should return req.query with period as month and end_at param' , function ( ) {
433
433
const expect_filters = {
434
434
$and : [
435
- { created_at : { $lt : '2019-01-24T23:59:59' } } ,
436
- { created_at : { $gte : '2018-12-24T00:00:00' } }
435
+ { created_at : { $lt : '2019-01-24T23:59:59' } } ,
436
+ { created_at : { $gte : '2018-12-24T00:00:00' } }
437
437
]
438
438
}
439
439
@@ -452,8 +452,8 @@ describe('queryFilter()', function () {
452
452
it ( 'should return req.query with period as year and start_at param' , function ( ) {
453
453
const expect_filters = {
454
454
$and : [
455
- { created_at : { $lt : '2019-02-24T23:59:59' } } ,
456
- { created_at : { $gte : '2018-02-24T00:00:00' } }
455
+ { created_at : { $lt : '2019-02-24T23:59:59' } } ,
456
+ { created_at : { $gte : '2018-02-24T00:00:00' } }
457
457
]
458
458
}
459
459
@@ -472,8 +472,8 @@ describe('queryFilter()', function () {
472
472
it ( 'should return req.query with period as year and end_at param' , function ( ) {
473
473
const expect_filters = {
474
474
$and : [
475
- { created_at : { $lt : '2019-02-24T23:59:59' } } ,
476
- { created_at : { $gte : '2018-02-24T00:00:00' } }
475
+ { created_at : { $lt : '2019-02-24T23:59:59' } } ,
476
+ { created_at : { $gte : '2018-02-24T00:00:00' } }
477
477
]
478
478
}
479
479
@@ -492,8 +492,8 @@ describe('queryFilter()', function () {
492
492
it ( 'should return req.query with today start_at for invalid period' , function ( ) {
493
493
const expect_filters = {
494
494
$and : [
495
- { created_at : { $lt : normalizeDate ( dateToString ( new Date ( ) ) , false ) } } ,
496
- { created_at : { $gte : normalizeDate ( dateToString ( new Date ( ) ) , true ) } }
495
+ { created_at : { $lt : normalizeDate ( dateToString ( new Date ( ) ) , false ) } } ,
496
+ { created_at : { $gte : normalizeDate ( dateToString ( new Date ( ) ) , true ) } }
497
497
]
498
498
}
499
499
@@ -512,8 +512,8 @@ describe('queryFilter()', function () {
512
512
it ( 'should return req.query with today end_at for invalid period' , function ( ) {
513
513
const expect_filters = {
514
514
$and : [
515
- { created_at : { $lt : normalizeDate ( dateToString ( new Date ( ) ) , false ) } } ,
516
- { created_at : { $gte : '2018-12-05T00:00:01' } }
515
+ { created_at : { $lt : normalizeDate ( dateToString ( new Date ( ) ) , false ) } } ,
516
+ { created_at : { $gte : '2018-12-05T00:00:01' } }
517
517
]
518
518
}
519
519
0 commit comments