mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-03 10:40:06 +00:00
fix(convert-to-csv): return empty string if table is not an array
This commit is contained in:
4
sasjs-tests/package-lock.json
generated
4
sasjs-tests/package-lock.json
generated
@@ -2388,7 +2388,7 @@
|
||||
"node_modules/@sasjs/adapter": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "file:../build/sasjs-adapter-5.0.0.tgz",
|
||||
"integrity": "sha512-O4MnLA6Tm2xoANU1uBJ5xMzEBeXVGkw38lR6LoiLIUhQOJY5gpwjb39oBPFqPfvCwjG0Jqjx7XcaE+g23pEfNw==",
|
||||
"integrity": "sha512-lbDWueAEnfNlu4OGrc9hBEzT0aoLfAy7eLd2nLHArrF6zukcSGBNhUgOqxIhlz4WeBdf1gt3nk1G7p5X1mrWYQ==",
|
||||
"hasInstallScript": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
@@ -20998,7 +20998,7 @@
|
||||
},
|
||||
"@sasjs/adapter": {
|
||||
"version": "file:../build/sasjs-adapter-5.0.0.tgz",
|
||||
"integrity": "sha512-O4MnLA6Tm2xoANU1uBJ5xMzEBeXVGkw38lR6LoiLIUhQOJY5gpwjb39oBPFqPfvCwjG0Jqjx7XcaE+g23pEfNw==",
|
||||
"integrity": "sha512-lbDWueAEnfNlu4OGrc9hBEzT0aoLfAy7eLd2nLHArrF6zukcSGBNhUgOqxIhlz4WeBdf1gt3nk1G7p5X1mrWYQ==",
|
||||
"requires": {
|
||||
"@sasjs/utils": "2.36.1",
|
||||
"axios": "0.26.0",
|
||||
|
||||
@@ -465,6 +465,6 @@ export const specialCaseTests = (adapter: SASjs): TestSuite => ({
|
||||
|
||||
return assertionRes
|
||||
}
|
||||
},
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
@@ -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('')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user