Skip to content

Commit

Permalink
Fixing unit tests using the csv-parse module to simulate an error on …
Browse files Browse the repository at this point in the history
…parsing.
  • Loading branch information
arithmetric committed Jul 1, 2020
1 parent 101b1ab commit 246ec4e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion test/parseCsv.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion test/parseSpaces.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 3 additions & 1 deletion test/parseTabs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 246ec4e

Please sign in to comment.