Skip to content

Commit

Permalink
test: add tests for #245
Browse files Browse the repository at this point in the history
  • Loading branch information
mrodrig committed Feb 23, 2024
1 parent 2a997d6 commit ea84114
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/json2csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,18 @@ export function runTests() {
assert.equal(csv, csvTestData.excludeKeyPattern);
});

// Test case for #245
it('should not escape nested dots in keys with nested dots in them if turned on via the option', () => {
const csv = json2csv(jsonTestData.nestedDotKeys, { escapeHeaderNestedDots: true }); // Default option value
assert.equal(csv, csvTestData.nestedDotKeys);
});

// Test case for #245
it('should not escape nested dots in keys with nested dots in them if turned off via the option', () => {
const csv = json2csv(jsonTestData.nestedDotKeys, { escapeHeaderNestedDots: false });
assert.equal(csv, csvTestData.nestedDotKeys.replace(/\\\./g, '.'));
});

it('should use a custom value parser function when provided', () => {
const updatedCsv = csvTestData.trimmedFields.split('\n');
const textRow = 'Parsed Value,Parsed Value,Parsed Value,Parsed Value,Parsed Value';
Expand Down

0 comments on commit ea84114

Please sign in to comment.