Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Commit

Permalink
tests: skip_empty_lines with trim
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Feb 9, 2021
1 parent 306c831 commit 314298a
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions test/option.skip_empty_lines.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,39 @@ describe 'Option `skip_empty_lines`', ->
describe 'false', ->

it 'dont skip by default', (next) ->
parse """
parse '''
ABC\n\nDEF
""", (err, data) ->
return next err if err
''', (err, data) ->

data.should.eql [
[ 'ABC' ]
[ '' ]
[ 'DEF' ]
]
next()
] unless err
next err

describe 'true', ->

it 'skip', (next) ->
parse """
parse '''
ABC\n\nDEF
""", skip_empty_lines: true, (err, data) ->
return next err if err
''', skip_empty_lines: true, (err, data) ->
data.should.eql [
[ 'ABC' ]
[ 'DEF' ]
]
next()
] unless err
next err

it 'skip respect parser.read', (next) ->
data = []
parser = parse skip_empty_lines: true
parser.write """
parser.write '''
20322051544,1979,8.8017226E7,ABC,45,2000-01-01
28392898392,1974,8.8392926E7,DEF,23,2050-11-27
"""
'''
parser.on 'readable', ->
while(d = parser.read())
data.push d
Expand All @@ -64,3 +63,18 @@ describe 'Option `skip_empty_lines`', ->
]
next()
parser.end()

it 'used conjointly with trim to ignore whitespaces', (next) ->
parse '''
a,b,c
\t
d,e,f
''',
skip_empty_lines: true
trim: true
, (err, records) ->
records.should.eql [
['a', 'b', 'c'],
['d', 'e', 'f']
] unless err
next err

0 comments on commit 314298a

Please sign in to comment.