@@ -216,6 +216,26 @@ describe('queryFilter()', function () {
216
216
} )
217
217
218
218
context ( 'when query contains date filters param' , function ( ) {
219
+ it ( 'should return req.query with set start_at params as today' , function ( done ) {
220
+ const expect_filters = {
221
+ $and : [
222
+ { created_at : { $lt : new Date ( ) . toISOString ( ) } } ,
223
+ { created_at : { $gte : new Date ( ) . toISOString ( ) } }
224
+ ]
225
+ }
226
+
227
+ const query = { start_at : 'today' }
228
+ const req = httpMocks . createRequest ( { method : 'GET' , url : '/' , query : query } )
229
+ const res = httpMocks . createResponse ( )
230
+
231
+ const options = JSON . parse ( JSON . stringify ( default_options ) )
232
+ options . default . filters = expect_filters
233
+
234
+ qs ( { } ) ( req , res , function next ( ) {
235
+ validateFilterWithDate ( req , options )
236
+ } )
237
+ done ( )
238
+ } )
219
239
it ( 'should return req.query with set start_at params as date' , function ( done ) {
220
240
const expect_filters = {
221
241
$and : [
@@ -300,14 +320,14 @@ describe('queryFilter()', function () {
300
320
done ( )
301
321
} )
302
322
303
- it ( 'should return req.query with set period and end_at param' , function ( done ) {
323
+ it ( 'should return req.query with set period and end_at param as dateTime ' , function ( done ) {
304
324
const expect_filters = {
305
325
$and : [
306
326
{ created_at : { $lt : new Date ( '2018-12-09' ) . toISOString ( ) } } ,
307
327
{ created_at : { $gte : new Date ( '2018-11-10' ) . toISOString ( ) } }
308
328
]
309
329
}
310
- const query = { period : '1m' , end_at : '2018-12-09 ' }
330
+ const query = { period : '1m' , end_at : '2018-12-09T00:00:00 ' }
311
331
const req = httpMocks . createRequest ( { method : 'GET' , url : '/' , query : query } )
312
332
const res = httpMocks . createResponse ( )
313
333
@@ -320,7 +340,7 @@ describe('queryFilter()', function () {
320
340
done ( )
321
341
} )
322
342
323
- it ( 'should return req.query with set period as day params' , function ( done ) {
343
+ it ( 'should return req.query with set period as day params and end_at as today ' , function ( done ) {
324
344
const now = new Date ( )
325
345
const today = dateToString ( new Date ( now . getFullYear ( ) , now . getMonth ( ) , now . getDate ( ) + 1 ) )
326
346
const beforeToday = dateToString ( new Date ( now . getFullYear ( ) , now . getMonth ( ) , now . getDate ( ) - 9 ) )
@@ -331,7 +351,7 @@ describe('queryFilter()', function () {
331
351
]
332
352
}
333
353
334
- const query = { period : '10d' }
354
+ const query = { period : '10d' , end_at : 'today' }
335
355
const req = httpMocks . createRequest ( { method : 'GET' , url : '/' , query : query } )
336
356
const res = httpMocks . createResponse ( )
337
357
0 commit comments