]> git.ardis.lu - csvio/commitdiff
Add additional tests for uncovered branches
authorArdis Lu <ardisglu@gmail.com>
Tue, 11 Feb 2025 06:33:25 +0000 (22:33 -0800)
committerArdis Lu <ardisglu@gmail.com>
Tue, 11 Feb 2025 06:33:25 +0000 (22:33 -0800)
test/core.test.js
test/normalization.test.js

index a02e4bd95fa6db80ae87f4be854dbb2efd71d0d7..3f0099f55c101004e97cf7783e05c36ff49238b4 100644 (file)
@@ -212,6 +212,17 @@ suite('CSVTransformer', { concurrency: true }, () => {
       .pipeThrough(new CSVTransformer(r => r))
       .pipeTo(csvStreamEqualWritable(csv));
   });
+  test('passes through raw input', { concurrency: true }, async () => {
+    await ReadableStream.from((function* () {
+      yield '["headerA","headerB"]';
+      yield '["111","222"]';
+    })())
+      .pipeThrough(new CSVTransformer(r => r, { handleHeaders: true, rawInput: true }))
+      .pipeTo(csvStreamEqualWritable([
+        ['headerA', 'headerB'],
+        ['111', '222']
+      ]));
+  });
   test('passes through raw output', { concurrency: true }, async () => {
     await createCSVMockStream([
       ['columnA', 'columnB'],
index 3463a2312ece375637367b04301fb0dc817cb054..1f01b8fed7bb1dbc4646d74628421b9c32d83b14 100644 (file)
@@ -207,6 +207,51 @@ suite('CSVNormalizer', { concurrency: true }, () => {
         ['a', 'b']
       ]));
   });
+  test('can pass through numbers', { concurrency: true }, async () => {
+    await createCSVMockStream([
+      ['columnA', 'columnB'],
+      ['123', '456']
+    ])
+      .pipeThrough(new CSVNormalizer([
+        { name: 'columnA', type: 'number' },
+        { name: 'columnB', type: 'number' }
+      ], { passthroughNumber: true }))
+      .pipeThrough(new CSVDenormalizer())
+      .pipeTo(csvStreamEqualWritable([
+        ['columnA', 'columnB'],
+        ['123', '456']
+      ]));
+  });
+  test('can pass through BigInt', { concurrency: true }, async () => {
+    await createCSVMockStream([
+      ['columnA', 'columnB'],
+      ['123', '456']
+    ])
+      .pipeThrough(new CSVNormalizer([
+        { name: 'columnA', type: 'bigint' },
+        { name: 'columnB', type: 'bigint' }
+      ], { passthroughBigInt: true }))
+      .pipeThrough(new CSVDenormalizer())
+      .pipeTo(csvStreamEqualWritable([
+        ['columnA', 'columnB'],
+        ['123', '456']
+      ]));
+  });
+  test('can pass through date', { concurrency: true }, async () => {
+    await createCSVMockStream([
+      ['columnA', 'columnB'],
+      ['2025-02-10', '2025-02-09']
+    ])
+      .pipeThrough(new CSVNormalizer([
+        { name: 'columnA', type: 'date' },
+        { name: 'columnB', type: 'date' }
+      ], { passthroughDate: true }))
+      .pipeThrough(new CSVDenormalizer())
+      .pipeTo(csvStreamEqualWritable([
+        ['columnA', 'columnB'],
+        ['2025-02-10', '2025-02-09']
+      ]));
+  });
   test('can ignore incorrect data types', { concurrency: true }, async (t) => {
     assertConsole(t, { warn: 2 });
     await createCSVMockStream([
This page took 0.045437 seconds and 4 git commands to generate.