mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-07 20:40:05 +00:00
fix(convert-to-csv): fix bug with escaping quoted string
This commit is contained in:
27
src/utils/convertToCsv.spec.ts
Normal file
27
src/utils/convertToCsv.spec.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { convertToCSV } from './convertToCsv'
|
||||
|
||||
describe('convertToCsv', () => {
|
||||
it('should convert single quoted values', () => {
|
||||
const data = [
|
||||
{ foo: `'bar'`, bar: 'abc' },
|
||||
{ foo: 'sadf', bar: 'def' },
|
||||
{ foo: 'asd', bar: `'qwert'` }
|
||||
]
|
||||
|
||||
const expectedOutput = `foo:$5. bar:$7.\r\n"'bar'",abc\r\nsadf,def\r\nasd,"'qwert'"`
|
||||
|
||||
expect(convertToCSV(data)).toEqual(expectedOutput)
|
||||
})
|
||||
|
||||
it('should convert double quoted values', () => {
|
||||
const data = [
|
||||
{ foo: `"bar"`, bar: 'abc' },
|
||||
{ foo: 'sadf', bar: 'def' },
|
||||
{ foo: 'asd', bar: `"qwert"` }
|
||||
]
|
||||
|
||||
const expectedOutput = `foo:$5. bar:$7.\r\n"""bar""",abc\r\nsadf,def\r\nasd,"""qwert"""`
|
||||
|
||||
expect(convertToCSV(data)).toEqual(expectedOutput)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user