Skip to content

Commit

Permalink
Add test and fix little bug
Browse files Browse the repository at this point in the history
  • Loading branch information
AGhost-7 committed Apr 13, 2016
1 parent 750a012 commit b3d696c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/index.coffee.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,11 @@ Implementation of the [`stream.Transform` API][transform]
row = null
if @options.columns is true
@options.columns = line
rawBuf = ''
return
else if typeof @options.columns is 'function'
@options.columns = @options.columns line
rawBuf = ''
return
@count++
if @options.columns?
Expand Down
38 changes: 38 additions & 0 deletions test/raw.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

require 'should'
parse = if process.env.CSV_COV then require '../lib-cov' else require '../src'

describe 'raw', ->
it 'includes escape chars', ->
str = """
"hello""world",LOL
"""
parse str, escape: '"', (err, data) ->
data[0].raw.should.eql str

it 'includes line breaks', ->
parse """
hello
my
friend
""", escape: '"', (err, data) ->
data[1].raw.should.match /\n$/

it 'skips columns', ->
parse """
name,last name
Boudreau,Jonathan
""", {}, (err, data) ->
data[0].raw.should.not.contain 'name'

it 'has the inner line breaks', ->
str = """
foo,"b
a
r"
"""
parse str, escape: '"', (err, data) ->
data[0].raw.should.eql str



0 comments on commit b3d696c

Please sign in to comment.