import { expect, tap } from '@git.zone/tstest/tapbundle'; import * as smartcsv from '../ts/index.js'; const fileString = [ 'Header 1;Header 2;"Header 3"', '"row1data1";"row1data2";"row1data3"', '"row2data1";row2data2;"row2data3"', ].join('\n'); tap.test('should create a valid csv', async () => { const testCsv = await smartcsv.Csv.createCsvFromString(fileString, { headers: true, unquote: true }); const result = await testCsv.exportAsObject(); expect(result[0]['Header 1']).toEqual('row1data1'); expect(result[0]['Header 3']).toEqual('row1data3'); expect(result[1]['Header 2']).toEqual('row2data2'); }); tap.test('should create a valid csv string', async () => { const createdCsvString = await smartcsv.Csv.createCsvStringFromArray([ { wow: 'hi', wow2: 'there' }, { wow: 'really', wow3: 'yes' }, ]); expect(createdCsvString).toEqual('wow,wow2,wow3\nhi,there,\nreally,,yes\n'); }); export default tap.start();