From 3d8bac5ce6db583d1f25d65653e32d8562104a73 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Mon, 27 Jan 2025 22:09:35 -0800 Subject: [PATCH] Add test for handleHeaders error handling --- test/core.test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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([ -- 2.47.3