1
0
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:
Krishna Acondy
2021-05-06 12:44:08 +01:00
parent bb2ad5bb9a
commit a32c0879b3
2 changed files with 36 additions and 13 deletions

View 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)
})
})