Skip to content

Commit 05cb677

Browse files
committed
Additional test for 100% coverage
1 parent d89d3cb commit 05cb677

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

test/config/testCsvFilesList.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ const fs = require('fs'),
3636
{key: 'invalidParsedValues', file: '../data/csv/invalidParsedValues.csv'},
3737
{key: 'firstColumnWrapCRLF', file: '../data/csv/firstColumnWrapCRLF.csv'},
3838
{key: 'emptyLastFieldValue', file: '../data/csv/emptyLastFieldValue.csv'},
39-
{key: 'emptyLastFieldValueNoEol', file: '../data/csv/emptyLastFieldValueNoEol.csv'}
39+
{key: 'emptyLastFieldValueNoEol', file: '../data/csv/emptyLastFieldValueNoEol.csv'},
40+
{key: 'lastCharFieldDelimiter', file: '../data/csv/lastCharFieldDelimiter.csv'}
4041
];
4142

4243
function readCsvFile(filePath) {

test/csv2json.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,16 @@ function runTests(jsonTestData, csvTestData) {
182182
});
183183

184184
// Test case for #161
185-
it('should properly convert empty field values if they occur at the end of the csv with no EOL at the end', (done) => {
185+
it('should properly convert an empty field value if it occurs at the end of the csv with no EOL at the end', (done) => {
186+
converter.csv2json(csvTestData.lastCharFieldDelimiter, (err, json) => {
187+
if (err) done(err);
188+
json.should.deepEqual(jsonTestData.emptyLastFieldValue);
189+
done();
190+
});
191+
});
192+
193+
// Test case for #161
194+
it('should properly convert two empty field values if they occur at the end of the csv with no EOL at the end', (done) => {
186195
converter.csv2json(csvTestData.emptyLastFieldValueNoEol, (err, json) => {
187196
if (err) done(err);
188197
json.should.deepEqual(jsonTestData.emptyLastFieldValueNoEol);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
data.uid,data.name
2+
,
3+
,

0 commit comments

Comments
 (0)