From: Ardis Lu Date: Tue, 5 Aug 2025 06:50:42 +0000 (-0700) Subject: Delete unnecessary negative test X-Git-Tag: v0.1.5~9 X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=674280ac852ba95e1db32a846ac8708a6284f274;p=csvio Delete unnecessary negative test The row length check in `csvStreamEqualWritable` now covers the original testing edge case that necessitated the negative test. Now the test will correctly fail without requiring the negative test to trigger the failure. --- diff --git a/test/core.test.js b/test/core.test.js index 76bb9ac..c7a97bb 100644 --- a/test/core.test.js +++ b/test/core.test.js @@ -6,7 +6,7 @@ import { setTimeout } from 'node:timers/promises'; import { pathToFileURL } from 'node:url'; import { ReadableStream, DecompressionStream, TextDecoderStream } from 'node:stream/web'; -import { csvStreamEqualWritable, csvStreamNotEqualWritable, createCSVMockStream, createTempFile } from './utils.js'; +import { csvStreamEqualWritable, createCSVMockStream, createTempFile } from './utils.js'; import { parsePathLike, createFileStream, CSVReader, CSVTransformer, CSVWriter } from '../src/core.js'; suite('CSVWriter.arrayToCSVString', { concurrency: true }, () => { @@ -271,19 +271,13 @@ suite('CSVReader', { concurrency: true }, () => { input: './data/blank.csv', output: [ [''] - ], - negativeOutput: [ - ['a'] ] } ]; - for (const { name, input, options = {}, output, negativeOutput } of vectors) { + for (const { name, input, options = {}, output } of vectors) { test(name, { concurrency: true }, async () => { 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(path, options).pipeTo(csvStreamNotEqualWritable(negativeOutput)); - } }); } test('can cancel', { concurrency: true }, async () => { diff --git a/test/utils.js b/test/utils.js index 71dcc71..4226dd1 100644 --- a/test/utils.js +++ b/test/utils.js @@ -31,25 +31,6 @@ export function csvStreamEqualWritable(csv) { }); } -/** - * Negative version of `csvStreamEqualWritable`. Tests that the piped stream is NOT equal to the given CSV. - * - * @param {Array>} csv A 2-D array representing the CSV file, where each inner array - * is a row of the CSV. - * @returns {WritableStream} A `WritableStream` sink of a CSV stream that will be compared against the given array. - */ -export function csvStreamNotEqualWritable(csv) { - let i = 0; - return new WritableStream({ - write(chunk) { - for (let j = 0; j < csv[i].length; j++) { - notStrictEqual(chunk[j], csv[i][j]); - } - i++; - } - }); -} - /** * @typedef AssertConsoleCounts Object containing the total number of times `console.log`, `console.info`, `console.warn`, * and `console.error` are expected to be called.