Skip to content

Commit

Permalink
feat: add test cases
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe committed Nov 28, 2023
1 parent 85b5146 commit 2be2bb4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions server/utils/csv-parser-helper.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { getJsonFromString } from './csv-parser-helper';

describe('getJsonFromString', () => {
it('return correct answer', async () => {
expect(await getJsonFromString('title,id\n1,2')).toEqual([
{
title: '1',
id: '2',
},
]);
});

it('return empty array when string is not in correct format', async () => {
expect(await getJsonFromString('1,2')).toEqual([]);
});
});

0 comments on commit 2be2bb4

Please sign in to comment.