Ensure that if the delimiter is set other than comma then download the file as '.txt' file. Fixes #4573

This commit is contained in:
Nagesh Dhope
2020-04-17 17:37:02 +05:30
committed by Akshay Joshi
parent 52d031f2d0
commit 8bdfa18efb
32 changed files with 131 additions and 46 deletions

View File

@@ -298,13 +298,22 @@ describe('queryToolActions', () => {
}));
});
it('calls trigger_csv_download with the query and the filename', () => {
it('calls trigger_csv_download with the query and the filename with .csv extension', () => {
let filename = 'data-' + time + '.csv';
queryToolActions.download(sqlEditorController);
expect(sqlEditorController.trigger_csv_download).toHaveBeenCalledWith(selectedQueryString, filename);
});
it('calls trigger_csv_download with the query and the filename with .txt extension', () => {
sqlEditorController.preferences.csv_field_separator = ';';
let filename = 'data-' + time + '.txt';
queryToolActions.download(sqlEditorController);
expect(sqlEditorController.trigger_csv_download).toHaveBeenCalledWith(selectedQueryString, filename);
});
});
describe('when there is no selection', () => {
@@ -622,6 +631,9 @@ describe('queryToolActions', () => {
table_name: 'iAmATable',
is_query_tool: true,
check_data_changes_to_execute_query: jasmine.createSpy('check_data_changes_to_execute_query'),
preferences: {
csv_field_separator: ',',
},
};
}
});