From 246ec4ec278fb2cf636e6b80498c318789d58789 Mon Sep 17 00:00:00 2001 From: Joe Turgeon Date: Wed, 1 Jul 2020 13:33:22 -0500 Subject: [PATCH] Fixing unit tests using the csv-parse module to simulate an error on parsing. --- test/parseCsv.spec.js | 4 +++- test/parseSpaces.spec.js | 4 +++- test/parseTabs.spec.js | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/test/parseCsv.spec.js b/test/parseCsv.spec.js index 73ba810..66a9262 100644 --- a/test/parseCsv.spec.js +++ b/test/parseCsv.spec.js @@ -30,7 +30,9 @@ describe('handler/parseCsv.js', function() { it('should fail if malformed CSV data is provided', function(done) { - handler.process({data: dataJson}) + // An unclosed quote should throw an error when processed by csv-parse. + const badData = '"test test\t'; + handler.process({data: badData}) .catch(function(err) { assert.ok(err, 'failure reported for malformed CSV data'); done(); diff --git a/test/parseSpaces.spec.js b/test/parseSpaces.spec.js index 3017679..fa0ee28 100644 --- a/test/parseSpaces.spec.js +++ b/test/parseSpaces.spec.js @@ -43,7 +43,9 @@ describe('handler/parseSpaces.js', function() { it('should fail if malformed space separated data is provided', function(done) { - handler.process({data: dataJson}) + // An unclosed quote should throw an error when processed by csv-parse. + const badData = '"test test'; + handler.process({data: badData}) .catch(function(err) { assert.ok(err, 'failure reported for malformed space separated data'); diff --git a/test/parseTabs.spec.js b/test/parseTabs.spec.js index 8d5e5d1..a25fc3f 100644 --- a/test/parseTabs.spec.js +++ b/test/parseTabs.spec.js @@ -30,7 +30,9 @@ describe('handler/parseTabs.js', function() { it('should fail if malformed tab separated data is provided', function(done) { - handler.process({data: dataJson}) + // An unclosed quote should throw an error when processed by csv-parse. + const badData = '"test test\t'; + handler.process({data: badData}) .catch(function(err) { assert.ok(err, 'failure reported for malformed tab separated data'); done();