From 56a62ae505b6b3ef6a24e8445a95e6276702f098 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 31 Mar 2022 20:32:39 +0200 Subject: [PATCH] Added tests for new CSV-JSON helper functions --- test/utils/helpers/csvjson.test.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/utils/helpers/csvjson.test.ts diff --git a/test/utils/helpers/csvjson.test.ts b/test/utils/helpers/csvjson.test.ts new file mode 100644 index 00000000..ff924779 --- /dev/null +++ b/test/utils/helpers/csvjson.test.ts @@ -0,0 +1,23 @@ +import { csvToJson, jsonToCsv } from '../../../src/utils/helpers/csvjson'; + +describe('csvjson', () => { + const csv = `"foo","bar","baz" +"hello","world","something" +"one","two","three"`; + const json = [ + { foo: 'hello', bar: 'world', baz: 'something' }, + { foo: 'one', bar: 'two', baz: 'three' }, + ]; + + describe('csvToJson', () => { + test('parses CSVs as expected', async () => { + expect(await csvToJson(csv)).toEqual(json); + }); + }); + + describe('jsonToCsv', () => { + test('parses JSON as expected', () => { + expect(jsonToCsv(json)).toEqual(csv); + }); + }); +});