From e1b09be139a33d64181d0dc8d5dd2c3c7f6c6331 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Tue, 8 Jul 2025 22:22:24 -0700 Subject: [PATCH] Add explicit test to remove extra headers --- test/normalization.test.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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'], -- 2.47.3