Skip to content

Commit 246ec4e

Browse files
committed
Fixing unit tests using the csv-parse module to simulate an error on parsing.
1 parent 101b1ab commit 246ec4e

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

test/parseCsv.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ describe('handler/parseCsv.js', function() {
3030

3131
it('should fail if malformed CSV data is provided',
3232
function(done) {
33-
handler.process({data: dataJson})
33+
// An unclosed quote should throw an error when processed by csv-parse.
34+
const badData = '"test test\t';
35+
handler.process({data: badData})
3436
.catch(function(err) {
3537
assert.ok(err, 'failure reported for malformed CSV data');
3638
done();

test/parseSpaces.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ describe('handler/parseSpaces.js', function() {
4343

4444
it('should fail if malformed space separated data is provided',
4545
function(done) {
46-
handler.process({data: dataJson})
46+
// An unclosed quote should throw an error when processed by csv-parse.
47+
const badData = '"test test';
48+
handler.process({data: badData})
4749
.catch(function(err) {
4850
assert.ok(err,
4951
'failure reported for malformed space separated data');

test/parseTabs.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ describe('handler/parseTabs.js', function() {
3030

3131
it('should fail if malformed tab separated data is provided',
3232
function(done) {
33-
handler.process({data: dataJson})
33+
// An unclosed quote should throw an error when processed by csv-parse.
34+
const badData = '"test test\t';
35+
handler.process({data: badData})
3436
.catch(function(err) {
3537
assert.ok(err, 'failure reported for malformed tab separated data');
3638
done();

0 commit comments

Comments
 (0)