@@ -216,6 +216,26 @@ describe('queryFilter()', function () {
216216 } )
217217
218218 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+ } )
219239 it ( 'should return req.query with set start_at params as date' , function ( done ) {
220240 const expect_filters = {
221241 $and : [
@@ -300,14 +320,14 @@ describe('queryFilter()', function () {
300320 done ( )
301321 } )
302322
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 ) {
304324 const expect_filters = {
305325 $and : [
306326 { created_at : { $lt : new Date ( '2018-12-09' ) . toISOString ( ) } } ,
307327 { created_at : { $gte : new Date ( '2018-11-10' ) . toISOString ( ) } }
308328 ]
309329 }
310- const query = { period : '1m' , end_at : '2018-12-09 ' }
330+ const query = { period : '1m' , end_at : '2018-12-09T00:00:00 ' }
311331 const req = httpMocks . createRequest ( { method : 'GET' , url : '/' , query : query } )
312332 const res = httpMocks . createResponse ( )
313333
@@ -320,7 +340,7 @@ describe('queryFilter()', function () {
320340 done ( )
321341 } )
322342
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 ) {
324344 const now = new Date ( )
325345 const today = dateToString ( new Date ( now . getFullYear ( ) , now . getMonth ( ) , now . getDate ( ) + 1 ) )
326346 const beforeToday = dateToString ( new Date ( now . getFullYear ( ) , now . getMonth ( ) , now . getDate ( ) - 9 ) )
@@ -331,7 +351,7 @@ describe('queryFilter()', function () {
331351 ]
332352 }
333353
334- const query = { period : '10d' }
354+ const query = { period : '10d' , end_at : 'today' }
335355 const req = httpMocks . createRequest ( { method : 'GET' , url : '/' , query : query } )
336356 const res = httpMocks . createResponse ( )
337357
0 commit comments