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 delayed parsing of rows past the initial rows', async () => {
const d = new DSVModel({
data: `a,b,c\nc,d,e\nf,g,h\ni,j,k`,
delimiter: ',',
initialRows: 2
});
expect(d.rowCount('column-header')).to.equal(1);
expect(d.rowCount('body')).to.equal(1);
expect(d.columnCount('row-header')).to.equal(1);
expect(d.columnCount('body')).to.equal(3);
expect([0, 1, 2].map(i => d.data('column-header', 0, i))).to.deep.equal([
'a',
'b',
'c'
]);
// Expected behavior is that all unparsed data is lumped into the final field.
expect([0, 1, 2].map(i => d.data('body', 0, i))).to.deep.equal([
it('handles having only a header', () => {
const d = new DSVModel({ data: 'a,b,c\n', delimiter: ',', header: true });
expect(d.rowCount('column-header')).to.equal(1);
expect(d.rowCount('body')).to.equal(0);
expect(d.columnCount('row-header')).to.equal(1);
expect(d.columnCount('body')).to.equal(3);
expect([0, 1, 2].map(i => d.data('column-header', 0, i))).to.deep.equal([
'a',
'b',
'c'
]);
});
this._subscription = this._data.subscribe(data => {
if (this.model) {
(this.model as DSVModel).dispose();
}
this.model = new DSVModel({ data, delimiter: "," });
});
super.onBeforeAttach(msg);
function onData(data: string) {
if (self.model) {
(self.model as DSVModel).dispose();
}
self.model = new DSVModel({
data: data,
delimiter: ','
});
}
}