From 4d2c3c69f4cb16eeb31ae55a36eb979b03889865 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Sun, 28 Jul 2024 21:44:10 -0400 Subject: [PATCH] test(tsv): Test a column with type but no format --- bids-validator/src/schema/applyRules.test.ts | 24 +++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/bids-validator/src/schema/applyRules.test.ts b/bids-validator/src/schema/applyRules.test.ts index df4b58b84..15c812889 100644 --- a/bids-validator/src/schema/applyRules.test.ts +++ b/bids-validator/src/schema/applyRules.test.ts @@ -62,6 +62,13 @@ const schemaDefs = { additional_columns: 'allowed', }, }, + made_up: { + MadeUp: { + columns: { + onset: 'required', + }, + }, + }, }, }, } @@ -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)', () => { @@ -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' })) + }) })