Skip to content

Commit

Permalink
✅ Add tests for it
Browse files Browse the repository at this point in the history
  • Loading branch information
dej611 committed Jan 4, 2022
1 parent 5336fd2 commit 5ba59ff
Show file tree
Hide file tree
Showing 3 changed files with 749 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/plugins/data/common/exports/export_csv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,28 @@ describe('CSV exporter', () => {
})
).toMatch('columnOne\r\n"\'=1"\r\n');
});

test('should filter out columns when there are meta information', () => {
const datatable = getDataTable({ multipleColumns: true });
// Make only the first column visible
datatable.columns[0].meta.dimensionName = 'First column';
expect(
datatableToCSV(datatable, {
...getDefaultOptions(),
escapeFormulaValues: true,
formatFactory: () => ({ convert: (v: unknown) => v } as FieldFormat),
})
).toMatch('columnOne\r\nvalue\r\n');
});

test('should not filter out columns if no meta information are found', () => {
const datatable = getDataTable({ multipleColumns: true });
expect(
datatableToCSV(datatable, {
...getDefaultOptions(),
escapeFormulaValues: true,
formatFactory: () => ({ convert: (v: unknown) => v } as FieldFormat),
})
).toMatch('columnOne,columnTwo\r\nvalue,5\r\n');
});
});
Loading

0 comments on commit 5ba59ff

Please sign in to comment.