-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #631 from olgn/fix-missing-trims
Fix missing trims
- Loading branch information
Showing
5 changed files
with
69 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const assert = require('chai').assert | ||
const validateTsvColumns = require('../validateTsvColumns') | ||
|
||
describe('validateTsvColumns', () => { | ||
const file = { | ||
name: 'participants.tsv', | ||
relativePath: '/participants.tsv', | ||
} | ||
const jsonContentsDict = { | ||
'/participants.json': { NewColumn: 'description' }, | ||
} | ||
|
||
it('allows for tabular files with columns that are described in the bids spec', () => { | ||
const tsvs = [ | ||
{ | ||
contents: 'participant_id\n', | ||
file: file, | ||
}, | ||
] | ||
const issues = validateTsvColumns(tsvs, {}) | ||
assert.lengthOf(issues, 0) | ||
}) | ||
it('checks for tabular files with custom columns not described in a data dictionary', () => { | ||
const tsvs = [ | ||
{ | ||
contents: 'header1\n', | ||
file: file, | ||
}, | ||
] | ||
const issues = validateTsvColumns(tsvs, {}) | ||
assert.lengthOf(issues, 1) | ||
assert.equal(issues[0].code, 82) | ||
}) | ||
it('allows custom columns if they are described in a data dictionary', () => { | ||
const tsvs = [ | ||
{ | ||
contents: 'NewColumn\n', | ||
file: file, | ||
}, | ||
] | ||
const issues = validateTsvColumns(tsvs, jsonContentsDict) | ||
assert.lengthOf(issues, 0) | ||
}) | ||
it('should trim the new line carriages created by windows tabular files,', () => { | ||
const tsvs = [ | ||
{ | ||
contents: 'participant_id\t\r\n', | ||
file: file, | ||
}, | ||
{ | ||
contents: 'participant_id\r\n', | ||
file: file, | ||
}, | ||
] | ||
const issues = validateTsvColumns(tsvs, {}) | ||
assert.lengthOf(issues, 0) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters