Skip to content

Commit

Permalink
more edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
anissa-agahchen committed Oct 12, 2021
1 parent 8855f4f commit 66d4eb5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions api/src/utils/media/csv/validation/csv-row-validator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ describe('getRequiredFieldsValidator', () => {
expect(csvWorkSheet.csvValidation.rowErrors).to.eql([]);
});

it('adds no errors when header does not exist', () => {
const requiredFieldsByHeader: string[] = ['Header1', 'Header2']; // fields for these headers are required
const validator = getRequiredFieldsValidator(requiredFieldsByHeader);

const xlsxWorkSheet = xlsx.utils.aoa_to_sheet([[], [5]]);

const csvWorkSheet = new CSVWorksheet('Sheet1', xlsxWorkSheet);

validator(csvWorkSheet);

expect(csvWorkSheet.csvValidation.rowErrors).to.eql([]);
});

it('adds errors for every field if required fields are provided and there are zero data rows in the worksheet', () => {
const requiredFieldsByHeader: string[] = ['Header1', 'Header2']; // fields for these headers are required

Expand Down

0 comments on commit 66d4eb5

Please sign in to comment.