Skip to content

Commit

Permalink
add simple test for populating dscontext subjects object
Browse files Browse the repository at this point in the history
  • Loading branch information
rwblair committed May 24, 2024
1 parent 544cda2 commit 3099205
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion bids-validator/src/schema/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ rootFileTree.files = [
]
rootFileTree.directories = [subjectFileTree]

const context = new BIDSContext(anatFileTree, dataFile, issues)
let context = new BIDSContext(anatFileTree, dataFile, issues)

Deno.test('test context LoadSidecar', async (t) => {
await context.loadSidecar(rootFileTree)
Expand All @@ -106,3 +106,16 @@ Deno.test('test context LoadSidecar', async (t) => {
assert(anatValue, 'anat')
})
})

context = new BIDSContext(rootFileTree, dataFile, issues)

Deno.test('test context loadSubjects', async (t) => {
await context.loadSubjects()
await t.step('context produces correct subjects object', () => {
assert(context.dataset.subjects, "subjects object exists")
assert(context.dataset.subjects.sub_dirs.length == 1, "there is only one sub dir found")
assert(context.dataset.subjects.sub_dirs[0] == 'sub-01', "that sub dir is sub-01")
// no participants.tsv so this should be empty
assert(context.dataset.subjects.participant_id == undefined, "no participant_id is populated")
})
})

0 comments on commit 3099205

Please sign in to comment.