Skip to content

Commit b09e0b3

Browse files
committed
test: Verify type checking additional columns
1 parent 69de065 commit b09e0b3

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/schema/tables.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,48 @@ Deno.test('tables eval* tests', async (t) => {
185185
assertEquals(issues.length, 1)
186186
})
187187

188+
await t.step('validate additional column with sidecar', () => {
189+
const context = {
190+
path: '/participants.tsv',
191+
extension: '.tsv',
192+
sidecar: {
193+
myAge: {
194+
Description: 'Age in weeks',
195+
Format: 'number',
196+
},
197+
mySex: {
198+
Description: 'Phenotypic sex',
199+
Format: 'string',
200+
Levels: {
201+
'F': { Description: 'Female' },
202+
'M': { Description: 'Male' },
203+
'O': { Description: 'Other' },
204+
},
205+
},
206+
},
207+
sidecarKeyOrigin: {
208+
myAge: '/participants.json',
209+
mySex: '/participants.json',
210+
},
211+
columns: new ColumnsMap(Object.entries({
212+
participant_id: ['sub-01', 'sub-02', 'sub-03'],
213+
myAge: ['10', '20', '89+'],
214+
mySex: ['M', 'F', 'O'],
215+
})),
216+
dataset: { issues: new DatasetIssues() },
217+
}
218+
const rule = schemaDefs.rules.tabular_data.modality_agnostic.Participants
219+
evalColumns(rule, context, schema, 'rules.tabular_data.modality_agnostic.Participants')
220+
221+
// myAge does not get the pseudo-age warning
222+
// mySex doesn't raise issues
223+
const issues = context.dataset.issues.get({ code: 'TSV_VALUE_INCORRECT_TYPE' })
224+
assertEquals(issues.length, 1)
225+
assertEquals(issues[0].subCode, 'myAge')
226+
assertEquals(issues[0].line, 4)
227+
assertEquals(issues[0].issueMessage, "'89+'")
228+
})
229+
188230
await t.step('verify column ordering', () => {
189231
const context = {
190232
path: '/sub-01/sub-01_scans.tsv',

0 commit comments

Comments
 (0)