You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
810 B
36 lines
810 B
import spectrum from "csv-spectrum";
|
|
import { parseString } from "fast-csv";
|
|
import test from "ava";
|
|
|
|
const simple_parse = (raw_csv) => {
|
|
const rows = raw_csv.split("\n");
|
|
const result = [];
|
|
|
|
for(let row of rows) {
|
|
result.push(row.split(','));
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
test('spectrum samples match', async t => {
|
|
const samples = await new Promise((res, rej) => {
|
|
spectrum((err, samples) => res(samples));
|
|
});
|
|
|
|
for(let sample of samples) {
|
|
const raw_csv = sample.csv.toString();
|
|
const good = [];
|
|
|
|
const count = await new Promise((res, rej) => {
|
|
parseString(raw_csv)
|
|
.on('error', err => rej(err))
|
|
.on('data', row => good.push(row))
|
|
.on('end', rowCount => res(rowCount));
|
|
});
|
|
|
|
const ours = simple_parse(raw_csv);
|
|
|
|
t.is(ours, good);
|
|
}
|
|
})
|
|
|