Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test coverage for code added in #2014 #2018

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions bids-validator/tests/hed.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,83 @@ describe('HED', function () {
assert.strictEqual(issues[1].code, 105)
})
})

it('should properly issue errors if HED data is used in a sidecar without using HEDVersion', () => {
const events = [
{
file: {
path: '/sub01/sub01_task-test_events.tsv',
relativePath: '/sub01/sub01_task-test_events.tsv',
},
path: '/sub01/sub01_task-test_events.tsv',
contents: 'onset\tduration\ttest\n' + '7\tsomething\tone\n',
},
]
const jsonDictionary = {
'/sub01/sub01_task-test_events.json': {
test: {
HED: {
one: 'Train',
},
},
},
'/dataset_description.json': {},
}

return validateHed(events, jsonDictionary, jsonFiles, '').then((issues) => {
assert.strictEqual(issues.length, 1)
assert.strictEqual(issues[0].code, 109)
})
})

it('should properly issue errors if HED data is used in a TSV file without using HEDVersion', () => {
const events = [
{
file: {
path: '/sub01/sub01_task-test_events.tsv',
relativePath: '/sub01/sub01_task-test_events.tsv',
},
path: '/sub01/sub01_task-test_events.tsv',
contents: 'onset\tduration\tHED\n' + '7\tsomething\tHuman\n',
},
]
const jsonDictionary = {
'/sub01/sub01_task-test_events.json': {},
'/dataset_description.json': {},
}

return validateHed(events, jsonDictionary, jsonFiles, '').then((issues) => {
assert.strictEqual(issues.length, 1)
assert.strictEqual(issues[0].code, 109)
})
})

it('should throw an issue if HEDVersion is invalid', () => {
const events = [
{
file: {
path: '/sub01/sub01_task-test_events.tsv',
relativePath: '/sub01/sub01_task-test_events.tsv',
},
path: '/sub01/sub01_task-test_events.tsv',
contents:
'onset\tduration\ttest\tHED\n' + '7\tsomething\tone\tSpeed/30 mph\n',
},
]
const jsonDictionary = {
'/sub01/sub01_task-test_events.json': {
myCodes: {
HED: {
one: 'Duration/5 s',
},
},
},
'/dataset_description.json': { HEDVersion: 'one:two:8.0.0' },
}

return validateHed(events, jsonDictionary, jsonFiles, '').then((issues) => {
assert.strictEqual(issues.length, 1)
assert.strictEqual(issues[0].code, 104)
})
})
})
Loading