]> git.ardis.lu - csvio/commitdiff
Add test for handleHeaders error handling
authorArdis Lu <ardisglu@gmail.com>
Tue, 28 Jan 2025 06:09:35 +0000 (22:09 -0800)
committerArdis Lu <ardisglu@gmail.com>
Tue, 28 Jan 2025 06:09:35 +0000 (22:09 -0800)
test/core.test.js

index 9418c38239d816402e10074a5de7def3e78027d1..3ff4edba784cf0573b92f4171ba6be65e01322b5 100644 (file)
@@ -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([
This page took 0.035859 seconds and 4 git commands to generate.