Skip to content

Commit

Permalink
test(csv-stringify): escape examples
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Mar 3, 2023
1 parent 31f3908 commit 7633d7f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/csv-stringify/samples/option.escape.custom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

import { stringify } from 'csv-stringify/sync';
import assert from 'assert';

const records = stringify([
['a "value"'],
], {escape: '\\'});

assert.equal(records, '"a \\"value\\""\n')
9 changes: 9 additions & 0 deletions packages/csv-stringify/samples/option.escape.default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

import { stringify } from 'csv-stringify/sync';
import assert from 'assert';

const records = stringify([
['a "value"'],
]);

assert.equal(records, '"a ""value"""\n')
7 changes: 7 additions & 0 deletions packages/csv-stringify/test/option.escape.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import { stringify } from '../lib/index.js'

describe 'Option `escape`', ->

it 'default', (next) ->
stringifier = stringify [
['abc', 'def']
], ->
stringifier.options.escape.should.eql('"')
next()

it 'validation', ->
stringify [], escape: ','
stringify [], escape: Buffer.from ','
Expand Down

0 comments on commit 7633d7f

Please sign in to comment.