From: Ardis Lu Date: Fri, 14 Nov 2025 06:52:01 +0000 (-0800) Subject: Add additional AsyncGenerator tests X-Git-Tag: v0.1.10~3 X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=b4def2ad6cc705d95c9c64f92b00384244d2a62b;p=csvio Add additional AsyncGenerator tests --- diff --git a/test/core.test.js b/test/core.test.js index 0f8ac08..247cda4 100644 --- a/test/core.test.js +++ b/test/core.test.js @@ -603,6 +603,48 @@ suite('CSVTransformer', { concurrency: true }, () => { ['2c'] ])); }); + test('handles AsyncGenerator (async function*) with batches', { concurrency: true }, async (t) => { + await createCSVMockStream([ + ['columnA'], + ['1'], + ['2'] + ]) + .pipeThrough(new CSVTransformer(async function* (row) { + yield [`${row[0][0]} + ${row[1][0]} a`]; + yield [`${row[0][0]} + ${row[1][0]} b`]; + yield [`${row[0][0]} + ${row[1][0]} c`]; + }, { maxBatchSize: 2 })) + .pipeTo(csvStreamEqualWritable([ + ['columnA'], + ['1 + 2 a'], + ['1 + 2 b'], + ['1 + 2 c'] + ])); + }); + test('handles AsyncGenerator (async function*) with maxConcurrent', { concurrency: true }, async (t) => { + await createCSVMockStream([ + ['columnA'], + ['1'], + ['2'], + ['3'], + ['4'] + ]) + .pipeThrough(new CSVTransformer(async function* (row) { + yield [`${row[0]}a`]; + yield [`${row[0]}b`]; + }, { maxConcurrent: 4 })) + .pipeTo(csvStreamEqualWritable([ + ['columnA'], + ['1a'], + ['1b'], + ['2a'], + ['2b'], + ['3a'], + ['3b'], + ['4a'], + ['4b'] + ])); + }); test('handles ReadableStream', { concurrency: true }, async (t) => { await createCSVMockStream([ ['columnA'],