Skip to content

Commit

Permalink
test(csv-stringify): quoted_match default value
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Mar 3, 2023
1 parent fe6348d commit feae510
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions packages/csv-stringify/test/option.quoted_match.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@ import { stringify } from '../lib/index.js'

describe 'Option `quoted_match`', ->

it 'default to `null`', (next) ->
stringifier = stringify [
['abc', 'def']
], ->
should(stringifier.options.quoted_match).be.null()
next()

it 'a string', (next) ->
count = 0
data = ''
stringifier = stringify [
stringify [
['abc', 'def']
], quoted_match: 'e', eof: false, (err, data) ->
data.should.eql '''
Expand All @@ -17,7 +24,7 @@ describe 'Option `quoted_match`', ->
it 'a regex', (next) ->
count = 0
data = ''
stringifier = stringify [
stringify [
['abcd', 'efg']
], quoted_match: /^\w{3}$/, eof: false, (err, data) ->
data.should.eql '''
Expand All @@ -28,7 +35,7 @@ describe 'Option `quoted_match`', ->
it 'an array', (next) ->
count = 0
data = ''
stringifier = stringify [
stringify [
['ab', 'cd', 'efg']
], quoted_match: ['d', /^\w{3}$/], eof: false, (err, data) ->
data.should.eql '''
Expand All @@ -39,7 +46,7 @@ describe 'Option `quoted_match`', ->
it 'an empty string regex with no other "quoted" options (#344)', (next) ->
count = 0
data = ''
stringifier = stringify [
stringify [
['a', null, undefined, '', 'b']
], quoted_match: /^$/, eof: false, (err, data) ->
data.should.eql '''
Expand All @@ -50,7 +57,7 @@ describe 'Option `quoted_match`', ->
it 'an empty string regex with all other "quoted" options set to false (#344)', (next) ->
count = 0
data = ''
stringifier = stringify [
stringify [
['a', null, undefined, '', 'b']
], quoted: false, quoted_empty: false, quoted_string: false, quoted_match: /^$/, eof: false, (err, data) ->
data.should.eql '''
Expand All @@ -61,7 +68,7 @@ describe 'Option `quoted_match`', ->
it 'an empty string regex has higher priority than the "quoted" option', (next) ->
count = 0
data = ''
stringifier = stringify [
stringify [
['a', null, undefined, '', 'b']
], quoted: true, quoted_match: /^$/, eof: false, (err, data) ->
data.should.eql '''
Expand All @@ -72,7 +79,7 @@ describe 'Option `quoted_match`', ->
it "an empty string regex does not conflict with quoted_string set to true", (next) ->
count = 0
data = ''
stringifier = stringify [
stringify [
['a', null, undefined, '', 'b']
], quoted_string: true, quoted_match: /^$/, eof: false, (err, data) ->
data.should.eql '''
Expand All @@ -83,7 +90,7 @@ describe 'Option `quoted_match`', ->
it "an empty string regex does not conflict with quoted_empty set to true", (next) ->
count = 0
data = ''
stringifier = stringify [
stringify [
['a', null, undefined, '' , 'b']
], quoted_empty: true, quoted_match: /^$/, eof: false, (err, data) ->
data.should.eql '''
Expand Down

0 comments on commit feae510

Please sign in to comment.