@@ -12,9 +12,11 @@ await requestReadPermission()
1212// Use this file for testing file behavior
1313const testUrl = import . meta. url
1414const testPath = fromFileUrl ( testUrl )
15- const testDir = dirname ( testPath )
15+ const testDir = dirname ( testPath ) // $REPO/src/files
1616const testFilename = basename ( testPath )
17+ const repoRoot = dirname ( dirname ( dirname ( testPath ) ) )
1718const ignore = new FileIgnoreRules ( [ ] )
19+ const prune = new FileIgnoreRules ( [ 'derivatives' ] , false )
1820
1921Deno . test ( 'Deno implementation of BIDSFile' , async ( t ) => {
2022 await t . step ( 'implements basic file properties' , ( ) => {
@@ -53,7 +55,7 @@ Deno.test('Deno implementation of BIDSFile', async (t) => {
5355 'strips BOM characters when reading UTF-8 via .text()' ,
5456 async ( ) => {
5557 // BOM is invalid in JSON but shows up often from certain tools, so abstract handling it
56- const bomDir = join ( testPath , '..' , '.. ', 'tests' )
58+ const bomDir = join ( repoRoot , 'src ' , 'tests' )
5759 const bomFilename = 'bom-utf8.json'
5860 const file = new BIDSFileDeno ( bomDir , bomFilename , ignore )
5961 const text = await file . text ( )
@@ -75,4 +77,16 @@ Deno.test('Deno implementation of FileTree', async (t) => {
7577 assert ( testObj !== undefined )
7678 assertEquals ( testObj . path , `/${ parent } /${ testFilename } ` )
7779 } )
80+
81+ await t . step ( 'implements pruning' , async ( ) => {
82+ const dsDir = join ( repoRoot , 'tests' , 'data' , 'valid_dataset' )
83+ const derivFile =
84+ 'derivatives/fmriprep/sub-01/ses-01/func/sub-01_ses-01_task-rest_confounds.tsv.gz'
85+
86+ const fullTree = await readFileTree ( dsDir )
87+ assert ( fullTree . get ( derivFile ) )
88+
89+ const prunedTree = await readFileTree ( dsDir , prune )
90+ assert ( ! prunedTree . get ( derivFile ) )
91+ } )
7892} )
0 commit comments