11import { assertEquals } from '@std/assert'
22import { SEPARATOR_PATTERN } from '@std/path'
3- import { BIDSContext } from '../schema/context.ts'
3+ import { makeBIDSContext } from '../schema/context.test .ts'
44import { _findRuleMatches , findDirRuleMatches , hasMatch } from './filenameIdentify.ts'
55import { BIDSFileDeno } from '../files/deno.ts'
66import { FileIgnoreRules } from '../files/ignore.ts'
@@ -27,7 +27,7 @@ Deno.test('test _findRuleMatches', async (t) => {
2727 await t . step ( 'Rule stem matches' , async ( ) => {
2828 const fileName = 'participants.json'
2929 const file = new BIDSFileDeno ( PATH , fileName , ignore )
30- const context = new BIDSContext ( file )
30+ const context = await makeBIDSContext ( file )
3131 _findRuleMatches ( node , schemaPath , context )
3232 assertEquals ( context . filenameRules [ 0 ] , schemaPath )
3333 } )
@@ -38,7 +38,7 @@ Deno.test('test _findRuleMatches', async (t) => {
3838 async ( ) => {
3939 const fileName = 'task-rest_bold.json'
4040 const file = new BIDSFileDeno ( PATH , fileName , ignore )
41- const context = new BIDSContext ( file )
41+ const context = await makeBIDSContext ( file )
4242 _findRuleMatches ( recurseNode , schemaPath , context )
4343 assertEquals ( context . filenameRules [ 0 ] , `${ schemaPath } .recurse` )
4444 } ,
@@ -49,7 +49,7 @@ Deno.test('test hasMatch', async (t) => {
4949 await t . step ( 'hasMatch' , async ( ) => {
5050 const fileName = '/sub-01/ses-01/func/sub-01_ses-01_task-nback_run-01_bold.nii'
5151 const file = new BIDSFileDeno ( PATH , fileName , ignore )
52- const context = new BIDSContext ( file )
52+ const context = await makeBIDSContext ( file )
5353 hasMatch ( schema , context )
5454 } )
5555
@@ -58,7 +58,7 @@ Deno.test('test hasMatch', async (t) => {
5858 const [ dir , base ] = tmpFile . split ( SEPARATOR_PATTERN )
5959 const file = new BIDSFileDeno ( dir , `/${ base } ` , ignore )
6060
61- const context = new BIDSContext ( file )
61+ const context = await makeBIDSContext ( file )
6262 await hasMatch ( schema , context )
6363 assertEquals (
6464 context . dataset . issues . get ( {
@@ -73,7 +73,7 @@ Deno.test('test hasMatch', async (t) => {
7373 const path = `${ PATH } /../bids-examples/fnirs_automaticity`
7474 const fileName = 'events.json'
7575 const file = new BIDSFileDeno ( path , fileName , ignore )
76- const context = new BIDSContext ( file )
76+ const context = await makeBIDSContext ( file )
7777 context . filenameRules = [
7878 'rules.files.raw.events.events__mri' ,
7979 'rules.files.raw.events.events__pet' ,
@@ -87,7 +87,7 @@ Deno.test('test directoryIdentify', async (t) => {
8787 await t . step ( 'Test entity based rule' , async ( ) => {
8888 const fileName = '/sub-01/'
8989 const file = new BIDSFileDeno ( PATH , fileName , ignore )
90- const context = new BIDSContext ( file )
90+ const context = await makeBIDSContext ( file )
9191 context . directory = true
9292 await findDirRuleMatches ( schema , context )
9393 assertEquals ( context . filenameRules . length , 1 )
@@ -96,7 +96,7 @@ Deno.test('test directoryIdentify', async (t) => {
9696 await t . step ( 'Test name based rule' , async ( ) => {
9797 const fileName = '/derivatives/'
9898 const file = new BIDSFileDeno ( PATH , fileName , ignore )
99- const context = new BIDSContext ( file )
99+ const context = await makeBIDSContext ( file )
100100 context . directory = true
101101 await findDirRuleMatches ( schema , context )
102102 assertEquals ( context . filenameRules . length , 1 )
@@ -105,7 +105,7 @@ Deno.test('test directoryIdentify', async (t) => {
105105 await t . step ( 'Test value based rule' , async ( ) => {
106106 const fileName = '/func/'
107107 const file = new BIDSFileDeno ( `${ PATH } /sub-01/ses-01` , fileName , ignore )
108- const context = new BIDSContext ( file )
108+ const context = await makeBIDSContext ( file )
109109 context . directory = true
110110 await findDirRuleMatches ( schema , context )
111111 assertEquals ( context . filenameRules . length , 1 )
0 commit comments