@@ -201,8 +201,8 @@ describe("Logs", function () {
201
201
it ( "Should throw error when start date is greater than end date in dev mode" , async function ( ) {
202
202
await cleanDb ( ) ;
203
203
204
- const startDate = Date . now ( ) ;
205
- const endDate = startDate - 86400000 ;
204
+ const startDate = Math . floor ( Date . now ( ) / 1000 ) ;
205
+ const endDate = startDate - 86400 ;
206
206
207
207
try {
208
208
await logsQuery . fetchAllLogs ( {
@@ -222,9 +222,8 @@ describe("Logs", function () {
222
222
it ( "Should return logs within the specified date range in dev mode" , async function ( ) {
223
223
await cleanDb ( ) ;
224
224
225
- const endDate = Date . now ( ) ;
226
- const startDate = endDate - 86400000 * 7 ;
227
-
225
+ const endDate = Math . floor ( Date . now ( ) / 1000 ) ;
226
+ const startDate = endDate - 86400 * 7 ;
228
227
const result = await logsQuery . fetchAllLogs ( {
229
228
dev : "true" ,
230
229
startDate : startDate . toString ( ) ,
@@ -235,14 +234,16 @@ describe("Logs", function () {
235
234
expect ( result ) . to . have . property ( "allLogs" ) ;
236
235
if ( result . allLogs . length > 0 ) {
237
236
result . allLogs . forEach ( ( log ) => {
238
- expect ( log ) . to . have . property ( "timestamp" ) ;
237
+ expect ( log ) . to . have . property ( "timestamp" ) . that . is . a ( "number" ) ;
238
+ expect ( log . timestamp ) . to . be . at . least ( startDate ) ;
239
+ expect ( log . timestamp ) . to . be . at . most ( endDate ) ;
239
240
} ) ;
240
241
}
241
242
} ) ;
242
243
243
244
it ( "Should ignore date filters when not in dev mode" , async function ( ) {
244
- const endDate = Date . now ( ) ;
245
- const startDate = endDate - 86400000 * 7 ;
245
+ const endDate = Math . floor ( Date . now ( ) / 1000 ) ;
246
+ const startDate = endDate - 86400 * 7 ;
246
247
247
248
const result = await logsQuery . fetchAllLogs ( {
248
249
dev : "false" ,
@@ -258,7 +259,7 @@ describe("Logs", function () {
258
259
} ) ;
259
260
260
261
it ( "Should handle only start date filter in dev mode" , async function ( ) {
261
- const startDate = Date . now ( ) - 86400000 * 14 ;
262
+ const startDate = Math . floor ( Date . now ( ) / 1000 ) - 86400 * 14 ;
262
263
263
264
const result = await logsQuery . fetchAllLogs ( {
264
265
dev : "true" ,
@@ -269,10 +270,17 @@ describe("Logs", function () {
269
270
expect ( result ) . to . have . property ( "allLogs" ) ;
270
271
expect ( result ) . to . have . property ( "prev" ) ;
271
272
expect ( result ) . to . have . property ( "next" ) ;
273
+
274
+ if ( result . allLogs . length > 0 ) {
275
+ result . allLogs . forEach ( ( log ) => {
276
+ expect ( log ) . to . have . property ( "timestamp" ) . that . is . a ( "number" ) ;
277
+ expect ( log . timestamp ) . to . be . at . least ( startDate ) ;
278
+ } ) ;
279
+ }
272
280
} ) ;
273
281
274
282
it ( "Should handle only end date filter in dev mode" , async function ( ) {
275
- const endDate = Date . now ( ) ;
283
+ const endDate = Math . floor ( Date . now ( ) / 1000 ) ;
276
284
277
285
const result = await logsQuery . fetchAllLogs ( {
278
286
dev : "true" ,
@@ -283,6 +291,13 @@ describe("Logs", function () {
283
291
expect ( result ) . to . have . property ( "allLogs" ) ;
284
292
expect ( result ) . to . have . property ( "prev" ) ;
285
293
expect ( result ) . to . have . property ( "next" ) ;
294
+
295
+ if ( result . allLogs . length > 0 ) {
296
+ result . allLogs . forEach ( ( log ) => {
297
+ expect ( log ) . to . have . property ( "timestamp" ) . that . is . a ( "number" ) ;
298
+ expect ( log . timestamp ) . to . be . at . most ( endDate ) ;
299
+ } ) ;
300
+ }
286
301
} ) ;
287
302
288
303
it ( "Should return null if no logs are presnet the logs for specific types" , async function ( ) {
0 commit comments