const vectors = [
{
name: 'parses simple CSV',
- input: './test/data/simple.csv',
+ input: './data/simple.csv',
output: [
['column1', 'column2', 'column3'],
['abc', 'def', 'ghi'],
},
{
name: 'parses escaping CSV',
- input: './test/data/escaping.csv',
+ input: './data/escaping.csv',
output: [
['name', 'value'],
['Three spaces', ' '],
},
{
name: 'parses escaping edges CSV',
- input: './test/data/escaping-edges.csv',
+ input: './data/escaping-edges.csv',
output: [
[',,,', '"""'],
['"""', ',,,'],
},
{
name: 'parses sparse CSV',
- input: './test/data/sparse.csv',
+ input: './data/sparse.csv',
output: [
['column1', 'column2', 'column3'],
[''],
},
{
name: 'parses line feed end-of-line CSV',
- input: './test/data/lf-eol.csv',
+ input: './data/lf-eol.csv',
output: [
['column1', 'column2'],
['a', 'b'],
},
{
name: 'parses byte order mark CSV',
- input: './test/data/bom.csv',
+ input: './data/bom.csv',
output: [
['column1', 'column2'],
['ab', 'cd'],
},
{
name: 'parses UTF-16 LE CSV',
- input: './test/data/utf-16le.csv',
+ input: './data/utf-16le.csv',
options: { encoding: 'utf-16le' },
output: [
['column1', 'column2'],
},
{
name: 'parses single value (no commas or newlines) CSV',
- input: './test/data/single-value.csv',
+ input: './data/single-value.csv',
output: [
['abc']
]
},
{
name: 'parses single column (no commas) CSV',
- input: './test/data/single-column.csv',
+ input: './data/single-column.csv',
output: [
['abc'],
['def'],
},
{
name: 'parses single row (no newlines) CSV',
- input: './test/data/single-row.csv',
+ input: './data/single-row.csv',
output: [
['abc', 'def', 'ghi']
]
},
{
name: 'parses blank CSV',
- input: './test/data/blank.csv',
+ input: './data/blank.csv',
output: [
['']
],
];
for (const { name, input, options = {}, output, negativeOutput } of vectors) {
test(name, { concurrency: true }, async () => {
- await new CSVReader(input, options).pipeTo(csvStreamEqualWritable(output));
+ const path = new URL(input, import.meta.url); // Makes the path relative to this file, not the command's execution directory
+ await new CSVReader(path, options).pipeTo(csvStreamEqualWritable(output));
if (negativeOutput !== undefined) {
- await new CSVReader(input, options).pipeTo(csvStreamNotEqualWritable(negativeOutput));
+ await new CSVReader(path, options).pipeTo(csvStreamNotEqualWritable(negativeOutput));
}
});
}