Skip to content

Commit ea84114

Browse files
committed
test: add tests for #245
1 parent 2a997d6 commit ea84114

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/json2csv.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,18 @@ export function runTests() {
523523
assert.equal(csv, csvTestData.excludeKeyPattern);
524524
});
525525

526+
// Test case for #245
527+
it('should not escape nested dots in keys with nested dots in them if turned on via the option', () => {
528+
const csv = json2csv(jsonTestData.nestedDotKeys, { escapeHeaderNestedDots: true }); // Default option value
529+
assert.equal(csv, csvTestData.nestedDotKeys);
530+
});
531+
532+
// Test case for #245
533+
it('should not escape nested dots in keys with nested dots in them if turned off via the option', () => {
534+
const csv = json2csv(jsonTestData.nestedDotKeys, { escapeHeaderNestedDots: false });
535+
assert.equal(csv, csvTestData.nestedDotKeys.replace(/\\\./g, '.'));
536+
});
537+
526538
it('should use a custom value parser function when provided', () => {
527539
const updatedCsv = csvTestData.trimmedFields.split('\n');
528540
const textRow = 'Parsed Value,Parsed Value,Parsed Value,Parsed Value,Parsed Value';

0 commit comments

Comments
 (0)