Skip to content

Commit 45907f6

Browse files
committed
test: add test cases for issue #240 fix
1 parent bba8369 commit 45907f6

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

test/config/testCsvFilesList.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const csvFileConfig = [
4949
{key: 'quotedFieldWithNewline', file: '../data/csv/quotedFieldWithNewline.csv'},
5050
{key: 'falsyValues', file: '../data/csv/falsyValues.csv'},
5151
{key: 'nestedNotUnwoundObjects', file: '../data/csv/nestedNotUnwoundObjects.csv'},
52+
{key: 'newlineWithWrapDelimiters', file: '../data/csv/newlineWithWrapDelimiters.csv'},
5253
];
5354

5455
function readCsvFile(filePath: string) {

test/config/testJsonFilesList.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@ export default {
4141
nestedDotKeysWithArrayExpandedUnwound: require('../data/json/nestedDotKeysWithArrayExpandedUnwound.json'),
4242
emptyColumns: require('../data/json/emptyColumns.json'),
4343
quotedFieldWithNewline: require('../data/json/quotedFieldWithNewline.json'),
44-
falsyValues: require('../data/json/falsyValues.json')
44+
falsyValues: require('../data/json/falsyValues.json'),
45+
newlineWithWrapDelimiters: require('../data/json/newlineWithWrapDelimiters'),
4546
};

test/csv2json.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,12 @@ export function runTests() {
376376
});
377377
assert.deepEqual(json, expectedJson);
378378
});
379+
380+
// Test case for issue #240
381+
it('should handle newline characters properly when inside of a field delimiter', () => {
382+
const json = csv2json(csvTestData.newlineWithWrapDelimiters);
383+
assert.deepEqual(json, jsonTestData.newlineWithWrapDelimiters);
384+
});
379385
});
380386
});
381387

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"Rating","Feedback","External Id"
2+
"5","
3+
Layout","id"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"Rating": "5",
4+
"Feedback": "\nLayout",
5+
"External Id": "id"
6+
}
7+
]

0 commit comments

Comments
 (0)