From ea841148e6f4414adce5028ce0610ebf4fe1b53d Mon Sep 17 00:00:00 2001 From: mrodrig Date: Thu, 22 Feb 2024 22:07:50 -0500 Subject: [PATCH] test: add tests for #245 --- test/json2csv.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/json2csv.ts b/test/json2csv.ts index 27a4748..f55e34b 100644 --- a/test/json2csv.ts +++ b/test/json2csv.ts @@ -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';