Skip to content

Commit

Permalink
test: Check .bidsignore is applied during browser filetree load
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Oct 7, 2024
1 parent 0b36291 commit 7591b82
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions bids-validator/src/files/browser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,60 @@ Deno.test('Browser implementation of FileTree', async (t) => {
sub01Tree.directories.push(anatTree)
assertEquals(tree, expectedTree)
})

await t.step('reads .bidsignore during load', async () => {
const ignore = new FileIgnoreRules([])
const files = [
new TestFile(
['ignored_but_absent\n', 'ignored_and_present\n'],
'.bidsignore',
'ds/.bidsignore',
),
new TestFile(
['{}'],
'dataset_description.json',
'ds/dataset_description.json',
),
new TestFile(
['tsv headers\n', 'column\tdata'],
'participants.tsv',
'ds/participants.tsv',
),
new TestFile(
['single subject test dataset'],
'README.md',
'ds/README.md',
),
new TestFile(
['Anything can be in an ignored file'],
'ignored_and_present',
'ds/ignored_and_present',
),
new TestFile(
['nifti file goes here'],
'sub-01_T1w.nii.gz',
'ds/sub-01/anat/sub-01_T1w.nii.gz',
),
]
const tree = await fileListToTree(files)
const expectedTree = new FileTree('/', '/', undefined)
const sub01Tree = new FileTree('/sub-01', 'sub-01', expectedTree)
const anatTree = new FileTree('/sub-01/anat', 'anat', sub01Tree)
expectedTree.files = files
.slice(0, 5)
.map((f) => {
const file = new BIDSFileBrowser(f, ignore)
file.parent = expectedTree
return file
})
expectedTree.directories.push(sub01Tree)
anatTree.files = [new BIDSFileBrowser(files[5], ignore)]
anatTree.files[0].parent = anatTree
sub01Tree.directories.push(anatTree)
assertEquals(tree, expectedTree)

assertEquals(tree.get('ignored_and_present')?.ignored, true)
})
})

Deno.test('Spread copies of BIDSFileBrowser contain name and path properties', async () => {
Expand Down

0 comments on commit 7591b82

Please sign in to comment.