Skip to content

Commit

Permalink
change unit test to express new behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceKatt committed May 3, 2021
1 parent bfb0291 commit f97d4de
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions src/utilities/index.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,16 @@ describe('jsonToTable', () => {
expect(result).toStrictEqual(expectedTable);
});

it('Throws when shape of data is inconsistent', () => {
it('Fills in missing data', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const badExample: any[] = [{ header_1: 'data' }, { header_2: 'data' }];

const t = (): string[][] => {
return jsonToTable(badExample);
};

expect(t).toThrow(SyntaxError);
});

it('Throws when extra headers exist on some data', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const badExample: any[] = [
{ header_1: 'data' },
{ header_1: 'data', header_2: 'data' },
const missingData: any[] = [{ header_1: 'data' }, { header_2: 'data' }];
const expectedTable = [
['header_1', 'header_2'],
['data', 'NULL'],
['NULL', 'data'],
];

const t = (): string[][] => {
return jsonToTable(badExample);
};

expect(t).toThrow(SyntaxError);
const table = jsonToTable(missingData);
expect(table).toStrictEqual(expectedTable);
});
});

0 comments on commit f97d4de

Please sign in to comment.