From: Ardis Lu Date: Thu, 10 Jul 2025 06:07:03 +0000 (-0700) Subject: Add explicit test for sparse CSV X-Git-Tag: v0.1.3~3 X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=747e09341009d8de1800e3b0ee4828aefe91b28f;p=csvio Add explicit test for sparse CSV --- diff --git a/test/normalization.test.js b/test/normalization.test.js index c57f353..a2e2466 100644 --- a/test/normalization.test.js +++ b/test/normalization.test.js @@ -273,6 +273,26 @@ suite('CSVNormalizer', { concurrency: true }, () => { ['a', 'b'] ])); }); + test('handles sparse CSV', { concurrency: true }, async () => { + await createCSVMockStream([ + ['sparse1', 'sparse2', 'sparse3'], + ['s1', '', ''], + ['', 's2', ''], + ['', '', 's3'] + ]) + .pipeThrough(new CSVNormalizer([ + { name: 'sparse1', type: 'string' }, + { name: 'sparse2', type: 'string' }, + { name: 'sparse3', type: 'string' }, + ])) + .pipeThrough(new CSVDenormalizer()) + .pipeTo(csvStreamEqualWritable([ + ['sparse1', 'sparse2', 'sparse3'], + ['s1', '', ''], + ['', 's2', ''], + ['', '', 's3'] + ])); + }); test('defaults to "string" type', { concurrency: true }, async () => { await createCSVMockStream([ ['columnA', 'columnB'],