2018-08-18 20:08:13 +00:00
|
|
|
import { expect, tap } from '@pushrocks/tapbundle';
|
2022-08-06 16:38:53 +00:00
|
|
|
import * as smartcsv from '../ts/index.js';
|
2018-05-10 17:47:14 +00:00
|
|
|
|
2018-08-18 20:08:13 +00:00
|
|
|
import * as smartfile from '@pushrocks/smartfile';
|
2018-05-10 17:47:14 +00:00
|
|
|
|
|
|
|
let fileString: string;
|
|
|
|
let testCsv: smartcsv.Csv;
|
|
|
|
|
2022-01-03 16:37:44 +00:00
|
|
|
tap.test('should read a file', async (tools) => {
|
2018-05-10 17:47:14 +00:00
|
|
|
fileString = smartfile.fs.toStringSync('./test/sample.csv');
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('should create a valid csv', async () => {
|
2019-10-10 16:30:29 +00:00
|
|
|
testCsv = await smartcsv.Csv.createCsvFromString(fileString, { headers: true, unquote: true });
|
2018-05-10 17:47:14 +00:00
|
|
|
const result = await testCsv.exportAsObject();
|
|
|
|
console.log(result);
|
|
|
|
});
|
|
|
|
|
2019-05-23 15:28:21 +00:00
|
|
|
tap.test('should create a valid csv string', async () => {
|
|
|
|
const createdCsvString = await smartcsv.Csv.createCsvStringFromArray([
|
|
|
|
{ wow: 'hi', wow2: 'there' },
|
2022-01-03 16:37:44 +00:00
|
|
|
{ wow: 'really', wow3: 'yes' },
|
2019-05-23 15:28:21 +00:00
|
|
|
]);
|
|
|
|
console.log(createdCsvString);
|
|
|
|
});
|
|
|
|
|
2018-05-10 17:47:14 +00:00
|
|
|
tap.start();
|