"use strict";

var _parseCsv = require("../parseCsv");
describe('parseCsv', () => {
  it('splits headers from data rows', () => {
    const result = (0, _parseCsv.parseCsv)('a,b\n1,2\n3,4');
    expect(result).toEqual({
      headers: ['a', 'b'],
      rows: [['1', '2'], ['3', '4']]
    });
  });
  it('drops fully empty rows', () => {
    const result = (0, _parseCsv.parseCsv)('a,b\n1,2\n\n3,4');
    expect(result).toEqual({
      headers: ['a', 'b'],
      rows: [['1', '2'], ['3', '4']]
    });
  });
  it('returns empty headers/rows for empty content', () => {
    expect((0, _parseCsv.parseCsv)('')).toEqual({
      headers: [],
      rows: []
    });
  });
});
describe('parseCsvSample', () => {
  it('returns the header plus at most maxRows data rows', () => {
    const content = 'a,b\n1,1\n2,2\n3,3\n4,4\n5,5';
    const result = (0, _parseCsv.parseCsvSample)(content, 2);
    expect(result).toEqual({
      headers: ['a', 'b'],
      rows: [['1', '1'], ['2', '2']]
    });
  });
  it('returns all rows when fewer than maxRows exist', () => {
    const result = (0, _parseCsv.parseCsvSample)('a,b\n1,1', 10);
    expect(result).toEqual({
      headers: ['a', 'b'],
      rows: [['1', '1']]
    });
  });
});
describe('unparseCsv', () => {
  it('round-trips through parseCsv', () => {
    const csv = (0, _parseCsv.unparseCsv)(['title', 'price'], [['Apple', '1'], ['Pear, Inc.', '2']]);
    expect((0, _parseCsv.parseCsv)(csv)).toEqual({
      headers: ['title', 'price'],
      rows: [['Apple', '1'], ['Pear, Inc.', '2']]
    });
  });
});
//# sourceMappingURL=parseCsv.spec.js.map