]> git.ardis.lu - csvio/commitdiff
Delete unnecessary negative test
authorArdis Lu <ardisglu@gmail.com>
Tue, 5 Aug 2025 06:50:42 +0000 (23:50 -0700)
committerArdis Lu <ardisglu@gmail.com>
Tue, 5 Aug 2025 06:50:42 +0000 (23:50 -0700)
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.

test/core.test.js
test/utils.js

index 76bb9ac779ded295b3f4a8246bd4a45f5975c6f4..c7a97bb385152eba1d870216896197dbf6fde3ba 100644 (file)
@@ -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 () => {
index 71dcc71b4fbfd191dbe2905163aafc414c72275f..4226dd1f30825e9777e95908871e9b4209e4b536 100644 (file)
@@ -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<Array<string>>} 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.
This page took 0.046004 seconds and 4 git commands to generate.