Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('handles changing the field delimiter', () => {
let data = `a\tb\tc\td\n0\t1\t2\t3\n4\t5\t6\t7\n`;
let options = { data, delimiter: '\t', rowDelimiter: '\n' };
let results;
results = parser({ ...options, columnOffsets: false });
expect(results.nrows).to.eql(3);
expect(results.offsets).to.eql([0, 8, 16]);
results = parser({ ...options, columnOffsets: true });
expect(results.nrows).to.eql(3);
expect(results.ncols).to.eql(4);
expect(results.offsets).to.eql([
0,
2,
4,
6,
8,
10,
12,
14,
16,
18,
20,
22
]);
it('handles quotes with field delimiters', () => {
let data = `a,"b,c",d\n"e","f"`;
let options = { data, rowDelimiter: '\n' };
let results;
results = parser({ ...options, columnOffsets: false });
expect(results.nrows).to.eql(2);
expect(results.offsets).to.eql([0, 10]);
results = parser({ ...options, columnOffsets: true });
expect(results.nrows).to.eql(2);
expect(results.ncols).to.eql(3);
expect(results.offsets).to.eql([0, 2, 8, 10, 14, 17]);
});