From: Ardis Lu Date: Tue, 28 Jan 2025 06:09:35 +0000 (-0800) Subject: Add test for handleHeaders error handling X-Git-Tag: v0.1.0~81 X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=3d8bac5ce6db583d1f25d65653e32d8562104a73;p=csvio Add test for handleHeaders error handling --- diff --git a/test/core.test.js b/test/core.test.js index 9418c38..3ff4edb 100644 --- a/test/core.test.js +++ b/test/core.test.js @@ -312,6 +312,19 @@ suite('CSVTransformer', { concurrency: true }, () => { ['2: caught'] ])); }); + test('passes handleHeaders to onError if handleHeaders is a function', { concurrency: true }, async () => { + await createCSVMockStream([ + ['columnA'], + ['1'], + ['2'] + ]) + .pipeThrough(new CSVTransformer(r => r, { handleHeaders: () => { throw new Error() }, onError: r => [`${r[0]}: caught`] })) + .pipeTo(csvStreamEqualWritable([ + ['columnA: caught'], + ['1'], + ['2'] + ])); + }); test('bubbles up errors re-raised by onError function', { concurrency: true }, async () => { await rejects( createCSVMockStream([