Add tests to results to CSV function

pull/10616/head
deniz kusefoglu 2017-09-12 14:59:03 -07:00
parent 66025e2336
commit c94a69366b
1 changed files with 25 additions and 0 deletions

View File

@ -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. ?