@@ -7,6 +7,8 @@ import { expect } from 'aegir/chai'
7
7
import all from 'it-all'
8
8
import { isNode } from 'wherearewe'
9
9
import { globSource } from '../../src/utils/glob-source.js'
10
+ import { toMtime } from '../../src/utils/to-mtime.js'
11
+ import type { Mtime } from 'ipfs-unixfs'
10
12
11
13
function fixtureDir ( ) : string {
12
14
const filename = fileURLToPath ( import . meta. url )
@@ -23,8 +25,8 @@ function findMode (file: string): number {
23
25
return fs . statSync ( fixture ( file ) ) . mode
24
26
}
25
27
26
- function findMtime ( file : string ) : Date {
27
- return fs . statSync ( fixture ( file ) ) . mtime
28
+ function findMtime ( file : string ) : Mtime {
29
+ return toMtime ( fs . statSync ( fixture ( file ) ) . mtime )
28
30
}
29
31
30
32
describe ( 'glob-source' , ( ) => {
@@ -228,28 +230,28 @@ describe('glob-source', () => {
228
230
}
229
231
230
232
const result = await all ( globSource ( fixtureDir ( ) , '{dir,dir/**/*}' , {
231
- mtime : new Date ( 5 )
233
+ mtime : toMtime ( new Date ( 5 ) )
232
234
} ) )
233
235
234
236
expect ( result ) . to . have . lengthOf ( 6 )
235
237
expect ( result ) . to . containSubset ( [ {
236
238
path : '/dir' ,
237
- mtime : new Date ( 5 )
239
+ mtime : toMtime ( new Date ( 5 ) )
238
240
} , {
239
241
path : '/dir/file-1.txt' ,
240
- mtime : new Date ( 5 )
242
+ mtime : toMtime ( new Date ( 5 ) )
241
243
} , {
242
244
path : '/dir/file-2.js' ,
243
- mtime : new Date ( 5 )
245
+ mtime : toMtime ( new Date ( 5 ) )
244
246
} , {
245
247
path : '/dir/file-3.css' ,
246
- mtime : new Date ( 5 )
248
+ mtime : toMtime ( new Date ( 5 ) )
247
249
} , {
248
250
path : '/dir/nested-dir' ,
249
- mtime : new Date ( 5 )
251
+ mtime : toMtime ( new Date ( 5 ) )
250
252
} , {
251
253
path : '/dir/nested-dir/other.txt' ,
252
- mtime : new Date ( 5 )
254
+ mtime : toMtime ( new Date ( 5 ) )
253
255
} ] )
254
256
} )
255
257
@@ -274,7 +276,7 @@ describe('glob-source', () => {
274
276
mtime : [ 5 , 0 ]
275
277
} ) )
276
278
277
- expect ( result ) . to . have . deep . nested . property ( '[0].mtime' , [ 5 , 0 ] )
279
+ expect ( result ) . to . have . deep . nested . property ( '[0].mtime' , toMtime ( [ 5 , 0 ] ) )
278
280
} )
279
281
280
282
it ( 'overrides mtime for file with UnixFS timespec' , async function ( ) {
@@ -286,6 +288,6 @@ describe('glob-source', () => {
286
288
mtime : { Seconds : 5 , FractionalNanoseconds : 0 }
287
289
} ) )
288
290
289
- expect ( result ) . to . have . deep . nested . property ( '[0].mtime' , { Seconds : 5 , FractionalNanoseconds : 0 } )
291
+ expect ( result ) . to . have . deep . nested . property ( '[0].mtime' , toMtime ( { Seconds : 5 , FractionalNanoseconds : 0 } ) )
290
292
} )
291
293
} )
0 commit comments