From bb9fca00c1b486014bfce50befc98c4aeecb941f Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Thu, 2 Jan 2025 20:33:26 -0800 Subject: [PATCH] Add tests for rawOutput --- test/core.test.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/core.test.js b/test/core.test.js index b0699a0..fe960b3 100644 --- a/test/core.test.js +++ b/test/core.test.js @@ -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]; -- 2.47.3