Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

49 lines (42 sloc) 1.523 kb
fs = require 'fs'
should = require 'should'
csv = require '..'
describe 'reader', ->
it 'should call data event when data is provided in from', (next) ->
csv().from('"1","2","3","4","5"')
.on 'data', (data) ->
data.length.should.eql 5
.on 'end', ->
next()
it 'should include empty last column', (next) ->
csv().from('"1","2","3","4","5",')
.on 'data', (data) ->
data.length.should.eql 6
.on 'end', ->
next()
it 'should include empty last column surrounded by quotes', (next) ->
csv().from('"1","2","3","4","5",""')
.on 'data', (data) ->
data.length.should.eql 6
.on 'end', ->
next()
it 'should include empty last column if followed by linebreak', (next) ->
csv().from('"1","2","3","4","5",""\n')
.on 'data', (data) ->
data.length.should.eql 6
.on 'end', ->
next()
it 'should call error event if exception is thrown in data event', (next) ->
count = 0
errors = 0
test = csv()
.toPath( "#{__dirname}/write/write_array.tmp" )
.on 'data', (data, index) ->
throw new Error "Error in data #{index}" if index % 10 is 0
.on 'error', (e) ->
e.message.should.equal 'Error in data 0'
next()
.on 'end', ->
false.should.be.ok
for i in [0...1000]
test.write ['Test '+i, i, '"'] if test.writable
Jump to Line
Something went wrong with that request. Please try again.