Skip to content

Commit 0ee43ce

Browse files
authored
Merge pull request #417 from SetCodesToFire/issue-392
Bug fix for when only two columns are there in valid events.tsv as well as test for it
2 parents d5b0383 + 0f6b148 commit 0ee43ce

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

tests/tsv.spec.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,37 @@ describe('TSV', function(){
4242
};
4343

4444
it('should require events files to have "onset" as first header', function () {
45-
var tsv = 'header-one\tduration\t4eader-three\n' +
45+
var tsv = 'header-one\tduration\theader-three\n' +
4646
'value-one\tvalue-two\tvalue-three';
4747
validate.TSV.TSV(eventsFile, tsv, [], function (issues) {
4848
assert(issues.length === 1 && issues[0].code === 20);
4949
});
5050
});
5151

5252
it('should require events files to have "duration" as second header', function () {
53-
var tsv = 'onset\theader-two\t4eader-three\n' +
53+
var tsv = 'onset\theader-two\theader-three\n' +
5454
'value-one\tvalue-two\tvalue-three';
5555
validate.TSV.TSV(eventsFile, tsv, [], function (issues) {
5656
assert(issues.length === 1 && issues[0].code === 21);
5757
});
5858
});
5959

6060
it('should not throw issues for a valid events file', function () {
61-
var tsv = 'onset\tduration\t4eader-three\n' +
61+
var tsv = 'onset\tduration\theader-three\n' +
6262
'value-one\tvalue-two\tvalue-three';
6363
validate.TSV.TSV(eventsFile, tsv, [], function (issues) {
6464
assert.deepEqual(issues, []);
6565
});
6666
});
6767

68+
it('should not throw issues for a valid events file with only two columns', function () {
69+
var tsv = 'onset\tduration\n' +
70+
'value-one\tvalue-two';
71+
validate.TSV.TSV(eventsFile, tsv, [], function (issues) {
72+
assert.deepEqual(issues, []);
73+
});
74+
});
75+
6876
it('should check for the presence of any stimulus files declared', function () {
6977
var tsv = 'onset\tduration\tstim_file\n' +
7078
'value-one\tvalue-two\timages/red-square.jpg';
@@ -87,15 +95,15 @@ describe('TSV', function(){
8795
};
8896

8997
it("should not allow participants.tsv files without participant_id columns", function () {
90-
var tsv = 'subject_id\theader-two\t4eader-three\n' +
98+
var tsv = 'subject_id\theader-two\theader-three\n' +
9199
'value-one\tvalue-two\tvalue-three';
92100
validate.TSV.TSV(participantsFile, tsv, [], function (issues) {
93101
assert(issues.length === 1 && issues[0].code === 48);
94102
});
95103
});
96104

97105
it("should allow a valid participants.tsv file", function () {
98-
var tsv = 'participant_id\theader-two\t4eader-three\n' +
106+
var tsv = 'participant_id\theader-two\theader-three\n' +
99107
'value-one\tvalue-two\tvalue-three';
100108
validate.TSV.TSV(participantsFile, tsv, [], function (issues) {
101109
assert.deepEqual(issues, []);

validators/tsv.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ var TSV = function TSV (file, contents, fileList, callback) {
8585
code: 20
8686
}));
8787
}
88-
if (headers[1] !== "duration"){
88+
if (headers[1].trim() !== "duration"){
8989
issues.push(new Issue({
9090
file: file,
9191
evidence: headers,

0 commit comments

Comments
 (0)