]> git.ardis.lu - csvio/commitdiff
Add tests for rawOutput
authorArdis Lu <ardisglu@gmail.com>
Fri, 3 Jan 2025 04:33:26 +0000 (20:33 -0800)
committerArdis Lu <ardisglu@gmail.com>
Fri, 3 Jan 2025 04:33:26 +0000 (20:33 -0800)
test/core.test.js

index b0699a03184bc61d48cb253a26965e75b9ea8196..fe960b3ce484f61ce2122860ac51d1b7ac106503 100644 (file)
@@ -157,6 +157,26 @@ suite('createCSVReadableStream', { concurrency: true }, () => {
 });
 
 suite('createCSVTransformStream', { concurrency: true }, () => {
+  test('passes through CSV', { concurrency: true }, async () => {
+    const csv = [
+      ['columnA', 'columnB'],
+      ['a', 'b']
+    ];
+    await createCSVMockStream(csv)
+      .pipeThrough(createCSVTransformStream(r => r))
+      .pipeTo(csvStreamEqualWritable(csv));
+  });
+  test('passes through raw output', { concurrency: true }, async () => {
+    await createCSVMockStream([
+      ['columnA', 'columnB'],
+      ['a', 'b']
+    ])
+      .pipeThrough(createCSVTransformStream(() => '["abc", "def"]', { includeHeaders: true, rawOutput: true }))
+      .pipeTo(csvStreamEqualWritable([
+        ['abc', 'def'],
+        ['abc', 'def']
+      ]));
+  });
   test('transforms data in place', { concurrency: true }, async () => {
     function timesTwo(row) {
       return [Number(row[0]) * 2, Number(row[1]) * 2];
This page took 0.046833 seconds and 4 git commands to generate.