Skip to content

Commit

Permalink
test: add test for #254
Browse files Browse the repository at this point in the history
  • Loading branch information
mrodrig committed Mar 21, 2024
1 parent 5ce5cac commit 33d7047
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/config/testCsvFilesList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const csvFileConfig = [
{key: 'excludeKeyPattern', file: '../data/csv/excludeKeyPattern.csv'},
{key: 'wildcardMatch', file: '../data/csv/wildcardMatch.csv'},
{key: 'arrayIndexesAsKeys', file: '../data/csv/arrayIndexesAsKeys.csv'},
{key: 'keyWithEndingDot', file:'../data/csv/keyWithEndingDot.csv'},
];

function readCsvFile(filePath: string) {
Expand Down
1 change: 1 addition & 0 deletions test/config/testJsonFilesList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ export default {
excludeKeyPattern: require('../data/json/excludeKeyPattern'),
wildcardMatch: require('../data/json/wildcardMatch.json'),
arrayIndexesAsKeys: require('../data/json/arrayIndexesAsKeys.json'),
keyWithEndingDot: require('../data/json/keyWithEndingDot.json'),
};
6 changes: 6 additions & 0 deletions test/csv2json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ export function runTests() {
const json = csv2json(csvTestData.quotedFieldWithNewline);
assert.deepEqual(json, jsonTestData.quotedFieldWithNewline);
});

// Test case for #254
it('should handle keys with ending dots', () => {
const json = csv2json(csvTestData.keyWithEndingDot);
assert.deepEqual(json, jsonTestData.keyWithEndingDot);
});
});

describe('Error Handling', () => {
Expand Down
2 changes: 2 additions & 0 deletions test/data/csv/keyWithEndingDot.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Account No.
01-1800-00
5 changes: 5 additions & 0 deletions test/data/json/keyWithEndingDot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
{
"Account No.": "01-1800-00"
}
]

0 comments on commit 33d7047

Please sign in to comment.