grafana/public/app/features/dataframe-import/utils.test.ts
Oscar Kilhed 8048a66e90
Dashboard: Add a feature that creates a table panel when a spreadsheet file is dropped on the dashboard. (#62688)
* drag files to dashboard

* use file name as panel title

* add file size limitation, file type limitation and error handling

* Refactor file parsing for code sharing

move accepted types and max size to file-import constants
show which file types are allowed in file type error

* update codeowners

* Adjust max size to 1mb
2023-02-09 15:16:17 +01:00

40 lines
981 B
TypeScript

import { formatFileTypes } from './utils';
describe('Dataframe import / Utils', () => {
describe('formatFileTypes', () => {
it('should nicely format file extensions', () => {
expect(
formatFileTypes({
'text/plain': ['.csv', '.txt'],
'application/json': ['.json'],
})
).toBe('.csv, .txt or .json');
});
it('should remove duplicates', () => {
expect(
formatFileTypes({
'text/plain': ['.csv', '.txt'],
'application/json': ['.json', '.txt'],
})
).toBe('.csv, .txt or .json');
});
it('should nicely format a single file type extension', () => {
expect(
formatFileTypes({
'text/plain': ['.txt'],
})
).toBe('.txt');
});
it('should nicely format two file type extension', () => {
expect(
formatFileTypes({
'text/plain': ['.txt', '.csv'],
})
).toBe('.txt or .csv');
});
});
});