]> git.ardis.lu - csvio/commitdiff
Add explicit test for sparse CSV
authorArdis Lu <ardisglu@gmail.com>
Thu, 10 Jul 2025 06:07:03 +0000 (23:07 -0700)
committerArdis Lu <ardisglu@gmail.com>
Thu, 10 Jul 2025 06:07:03 +0000 (23:07 -0700)
test/normalization.test.js

index c57f35310a24e5a78da941fbea13d88a5e222939..a2e2466fd274e927ddf9796461bccdd903bfcfa1 100644 (file)
@@ -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'],
This page took 0.034907 seconds and 4 git commands to generate.