Skip to content

Commit

Permalink
Add test case for special regex characters
Browse files Browse the repository at this point in the history
  • Loading branch information
donatj committed Jul 7, 2024
1 parent 9250cde commit 79014c8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,12 @@ describe('csvToMarkdown', function () {
var result = csvToMarkdown('"foo";"bar";"baz"\n"1";"2";"[foo -;- bar baz]"', ";", true);
assert.strictEqual(result, '| "foo" | "bar" | "baz" | \n|-------|-------|---------------------| \n| "1" | "2" | "[foo -;- bar baz]" | \n');
});

it('should handle delimiters that are regex special characters', function () {
var delimiters = ['[', ']', '\\', '/', '^', '$', '.', '|', '?', '*', '+', '(', ')', '{', '}', '-'];
delimiters.forEach(function (delimiter) {
var result = csvToMarkdown('a' + delimiter + 'b' + delimiter + 'c', delimiter, false);
assert.strictEqual(result, '| | | | \n|---|---|---| \n| a | b | c | \n', 'Failed for delimiter: "' + delimiter + '"');
});
});
});

0 comments on commit 79014c8

Please sign in to comment.