Skip to content

Commit

Permalink
test(tsv): Test a column with type but no format
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Jul 29, 2024
1 parent b1ce66a commit 4d2c3c6
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion bids-validator/src/schema/applyRules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ const schemaDefs = {
additional_columns: 'allowed',
},
},
made_up: {
MadeUp: {
columns: {
onset: 'required',
},
},
},
},
},
}
Expand Down Expand Up @@ -126,7 +133,7 @@ Deno.test(
},
)

Deno.test('check column contents', async (t) => {
Deno.test('evalColumns tests', async (t) => {
const schema = await loadSchema()

await t.step('check invalid datetime (scans.tsv:acq_time)', () => {
Expand All @@ -144,4 +151,19 @@ Deno.test('check column contents', async (t) => {
evalColumns(rule, context, schema, 'rules.tabular_data.modality_agnostic.Scans')
assert(context.issues.hasIssue({ key: 'TSV_VALUE_INCORRECT_TYPE_NONREQUIRED' }))
})

await t.step('check formatless column', () => {
const context = {
path: '/sub-01/sub-01_something.tsv',
extension: '.tsv',
sidecar: {},
columns: {
onset: ['1', '2', 'not a number'],
},
issues: new DatasetIssues(),
}
const rule = schemaDefs.rules.tabular_data.made_up.MadeUp
evalColumns(rule, context, schema, 'rules.tabular_data.made_up.MadeUp')
assert(context.issues.hasIssue({ key: 'TSV_VALUE_INCORRECT_TYPE' }))
})
})

0 comments on commit 4d2c3c6

Please sign in to comment.