Permalink
Browse files

Async callback in fromto test; Fix test after switching default lineb…

…reak to unix style
  • Loading branch information...
wdavidw committed Jul 1, 2012
1 parent 8b75b30 commit 1d926db6968bb2354e02bdb7a2f19716841a53ae
Showing with 1,015 additions and 15 deletions.
  1. +12 −11 test/fromto.coffee
  2. +1 −1 test/fromto/array_to_stream.out
  3. +1 −1 test/fromto/null.out
  4. +1 −1 test/write.coffee
  5. +1,000 −1 test/write/write.out
View
@@ -6,7 +6,7 @@ should = require 'should'
csv = require '..'
describe 'fromto', ->
- it 'Test fs stream', ->
+ it 'Test fs stream', (next) ->
csv()
.fromStream(fs.createReadStream "#{__dirname}/fromto/sample.in", flags: 'r' )
.toStream(fs.createWriteStream "#{__dirname}/fromto/sample.tmp", flags: 'w' )
@@ -15,8 +15,8 @@ describe 'fromto', ->
expect = fs.readFileSync( "#{__dirname}/fromto/sample.out" ).toString()
result = fs.readFileSync( "#{__dirname}/fromto/sample.tmp" ).toString()
result.should.eql expect
- fs.unlink "#{__dirname}/fromto/sample.tmp"
- it 'Test string without destination', ->
+ fs.unlink "#{__dirname}/fromto/sample.tmp", next
+ it 'Test string without destination', (next) ->
csv()
.from(fs.readFileSync( "#{__dirname}/fromto/sample.in" ).toString())
.on 'data', (data, index) ->
@@ -27,7 +27,8 @@ describe 'fromto', ->
data[0].should.eql '28392898392'
.on 'end', (count) ->
count.should.eql 2
- it 'Test string to stream', ->
+ next()
+ it 'Test string to stream', (next) ->
csv()
.from(fs.readFileSync( "#{__dirname}/fromto/string_to_stream.in" ).toString())
.toPath( "#{__dirname}/fromto/string_to_stream.tmp" )
@@ -42,9 +43,9 @@ describe 'fromto', ->
expect = fs.readFileSync( "#{__dirname}/fromto/string_to_stream.out" ).toString()
result = fs.readFileSync( "#{__dirname}/fromto/string_to_stream.tmp" ).toString()
result.should.eql expect
- fs.unlink "#{__dirname}/fromto/string_to_stream.tmp"
- it 'Test array to stream', ->
- # note: destination line breaks is windows styled because we can't guess it
+ fs.unlink "#{__dirname}/fromto/string_to_stream.tmp", next
+ it 'Test array to stream', (next) ->
+ # note: destination line breaks is unix styled because we can't guess it
data = [
["20322051544","1979.0","8.8017226E7","ABC","45","2000-01-01"]
["28392898392","1974.0","8.8392926E7","DEF","23","2050-11-27"]
@@ -63,9 +64,9 @@ describe 'fromto', ->
expect = fs.readFileSync( "#{__dirname}/fromto/array_to_stream.out" ).toString()
result = fs.readFileSync( "#{__dirname}/fromto/array_to_stream.tmp" ).toString()
result.should.eql expect
- fs.unlink "#{__dirname}/fromto/array_to_stream.tmp"
- it 'Test null', ->
- # note: destination line breaks is windows styled because we can't guess it
+ fs.unlink "#{__dirname}/fromto/array_to_stream.tmp", next
+ it 'should encode null as empty string', (next) ->
+ # note: destination line breaks is unix styled because we can't guess it
data = [
["20322051544",null,"8.8017226E7","ABC","45","2000-01-01"]
["28392898392","1974.0","8.8392926E7","DEF","23",null]
@@ -91,7 +92,7 @@ describe 'fromto', ->
expect = fs.readFileSync( "#{__dirname}/fromto/null.out" ).toString()
result = fs.readFileSync( "#{__dirname}/fromto/null.tmp" ).toString()
result.should.eql expect
- fs.unlink "#{__dirname}/fromto/null.tmp"
+ fs.unlink "#{__dirname}/fromto/null.tmp", next
@@ -1,2 +1,2 @@
-20322051544,1979.0,8.8017226E7,ABC,45,2000-01-01
+20322051544,1979.0,8.8017226E7,ABC,45,2000-01-01
28392898392,1974.0,8.8392926E7,DEF,23,2050-11-27
View
@@ -1,2 +1,2 @@
-,,8.8017226E7,,45,2000-01-01
+,,8.8017226E7,,45,2000-01-01
,1974.0,8.8392926E7,,23,
View
@@ -57,7 +57,7 @@ describe 'write', ->
fs.unlink "#{__dirname}/write/write_string.tmp", next
buffer = ''
for i in [0...1000]
- buffer += ''.concat "Test #{i}", ',', i, ',', '""""', "\r"
+ buffer += ''.concat "Test #{i}", ',', i, ',', '""""', "\n"
if buffer.length > 250
test.write buffer.substr 0, 250
buffer = buffer.substr 250
Oops, something went wrong.

0 comments on commit 1d926db

Please sign in to comment.