From c94a69366bdfa84ca6157c633d5b69e60bddc55e Mon Sep 17 00:00:00 2001 From: deniz kusefoglu Date: Tue, 12 Sep 2017 14:59:03 -0700 Subject: [PATCH] Add tests to results to CSV function --- ui/spec/shared/parsing/resultsToCSVSpec.js | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 ui/spec/shared/parsing/resultsToCSVSpec.js diff --git a/ui/spec/shared/parsing/resultsToCSVSpec.js b/ui/spec/shared/parsing/resultsToCSVSpec.js new file mode 100644 index 0000000000..508696af81 --- /dev/null +++ b/ui/spec/shared/parsing/resultsToCSVSpec.js @@ -0,0 +1,25 @@ +import resultsToCSV from 'shared/parsing/resultsToCSV' + +describe('resultsToCSV', () => { + it('parses results to an object with name and CSVString keys', () => { + const results = [ + { + series: [ + { + name: 'some_name', + columns: ['col1', 'col2', 'col3', 'col4'], + values: [[1, 2, 3, 4], [(5, 6, 7, 8)]], + }, + ], + }, + ] + const response = resultsToCSV(results) + expect(response).to.have.all.keys('name', 'CSVString') + expect(response.name).to.be.a('string') + expect('foobar').to.not.include('/') + expect(response.CSVString).to.be.a('string') + }) +}) + +// make sure name does not contain things that would not be allowed in a filename. +// handle edge cases for columns and values. ?