From b4def2ad6cc705d95c9c64f92b00384244d2a62b Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Thu, 13 Nov 2025 22:52:01 -0800 Subject: [PATCH] Add additional AsyncGenerator tests --- test/core.test.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) 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'], -- 2.47.3