Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('adjusts columns to match ncols with one row', () => {
let data = `a,b,c,d`;
let options = { data, rowDelimiter: '\n', ncols: 7 };
let results;
results = parser({ ...options, columnOffsets: false });
expect(results.nrows).to.eql(1);
expect(results.offsets).to.eql([0]);
results = parser({ ...options, columnOffsets: true });
expect(results.nrows).to.eql(1);
expect(results.ncols).to.eql(7);
expect(results.offsets).to.eql([0, 2, 4, 6, 7, 7, 7]);
});
it('handles a max row argument', () => {
let data = `a,b,c,d\n0,1,2,3\n4,5,6,7\n`;
let options = { data, rowDelimiter: '\n', maxRows: 2 };
let results;
results = parser({ ...options, columnOffsets: false });
expect(results.nrows).to.eql(2);
expect(results.offsets).to.eql([0, 8]);
results = parser({ ...options, columnOffsets: true });
expect(results.nrows).to.eql(2);
expect(results.ncols).to.eql(4);
expect(results.offsets).to.eql([0, 2, 4, 6, 8, 10, 12, 14]);
});