From: Ardis Lu Date: Fri, 3 Jan 2025 04:33:26 +0000 (-0800) Subject: Add tests for rawOutput X-Git-Tag: v0.1.0~142 X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=bb9fca00c1b486014bfce50befc98c4aeecb941f;p=csvio Add tests for rawOutput --- 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];