mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-10 02:07:26 +03:00
Added tests for new CSV-JSON helper functions
This commit is contained in:
parent
50072f5997
commit
56a62ae505
1 changed files with 23 additions and 0 deletions
23
test/utils/helpers/csvjson.test.ts
Normal file
23
test/utils/helpers/csvjson.test.ts
Normal file
|
@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in a new issue