From: Ardis Lu Date: Wed, 9 Jul 2025 05:22:24 +0000 (-0700) Subject: Add explicit test to remove extra headers X-Git-Tag: v0.1.3~11 X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=e1b09be139a33d64181d0dc8d5dd2c3c7f6c6331;p=csvio Add explicit test to remove extra headers --- diff --git a/test/normalization.test.js b/test/normalization.test.js index abd3521..16ec558 100644 --- a/test/normalization.test.js +++ b/test/normalization.test.js @@ -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'],