1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-06 20:10:05 +00:00

fix(convert-to-csv): return empty string if table is not an array

This commit is contained in:
Yury Shkoda
2022-03-03 17:31:23 +03:00
parent 4f3478c215
commit f6abb61c69
4 changed files with 12 additions and 3 deletions

View File

@@ -219,4 +219,10 @@ describe('convertToCsv', () => {
new Error('No table provided to be converted to CSV')
)
})
it('should empty string if table is not an array', () => {
const data = { [tableName]: true }
expect(convertToCSV(data, tableName)).toEqual('')
})
})

View File

@@ -11,6 +11,9 @@ export const convertToCSV = (
}
const table = data[tableName]
if (!Array.isArray(table)) return ''
let formats = data[`$${tableName}`]?.formats
let headers: string[] = []
let csvTest