-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(formatting,#446): Do not quote fields that do not contain a quote
- Loading branch information
1 parent
6969d3e
commit df20219
Showing
2 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as csv from '../../src'; | ||
import { RecordingStream } from '../__fixtures__'; | ||
|
||
describe('Issue #446 - https://github.com/C2FO/fast-csv/issues/446', () => { | ||
it('should not quote a field that contains a single quote if it is not the quote character', () => { | ||
return new Promise((res, rej) => { | ||
const rs = new RecordingStream(); | ||
const data: csv.RowArray[] = [["a quick' brown fox", 'jumped', 'over the lazy brown "dog"']]; | ||
|
||
csv.write(data, { | ||
headers: ['header1', 'header2', 'header3'], | ||
}) | ||
.pipe(rs) | ||
.on('error', rej) | ||
.on('finish', () => { | ||
expect(rs.data).toEqual([ | ||
'header1,header2,header3', | ||
`\na quick' brown fox,jumped,"over the lazy brown ""dog"""`, | ||
]); | ||
res(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters