]> git.ardis.lu - csvio/commitdiff
Add explicit test to remove extra headers
authorArdis Lu <ardisglu@gmail.com>
Wed, 9 Jul 2025 05:22:24 +0000 (22:22 -0700)
committerArdis Lu <ardisglu@gmail.com>
Wed, 9 Jul 2025 05:22:24 +0000 (22:22 -0700)
test/normalization.test.js

index abd35216f35a26780003d80f04b1175837611368..16ec5589153385b4a297f83eec445798a61e6aad 100644 (file)
@@ -174,7 +174,7 @@ suite('CSVNormalizer.fixExcelDate', { concurrency: true }, () => {
 });
 
 suite('CSVNormalizer', { concurrency: true }, () => {
-  test('can remove extra columns', { concurrency: true }, async () => {
+  test('can remove extra columns in CSV', { concurrency: true }, async () => {
     await createCSVMockStream([
       ['extra1', 'columnA', 'extra2', 'extra3', 'columnB'],
       ['123', 'a', '123', '123', 'b']
@@ -189,6 +189,24 @@ suite('CSVNormalizer', { concurrency: true }, () => {
         ['a', 'b']
       ]));
   });
+  test('can remove extra columns in headers input', { concurrency: true }, async () => {
+    await createCSVMockStream([
+      ['columnA', 'columnB'],
+      ['a', 'b']
+    ])
+      .pipeThrough(new CSVNormalizer([
+        { name: 'columnA', type: 'string' },
+        { name: 'columnB', type: 'string' },
+        { name: 'extra1', type: 'string' },
+        { name: 'extra2', type: 'string' },
+        { name: 'extra3', type: 'string' }
+      ]))
+      .pipeThrough(new CSVDenormalizer())
+      .pipeTo(csvStreamEqualWritable([
+        ['columnA', 'columnB'],
+        ['a', 'b']
+      ]));
+  });
   test('can reorder columns', { concurrency: true }, async () => {
     await createCSVMockStream([
       ['columnC', 'columnA', 'columnB'],
This page took 0.044266 seconds and 4 git commands to generate.