Permalink
Browse files

Move 'fromto' test to 'to'

  • Loading branch information...
1 parent 6784053 commit 46819a132ca2000151646fb3f359029f45b6fe48 @wdavidw committed Sep 30, 2012
Showing with 54 additions and 21 deletions.
  1. +0 −21 test/fromto.coffee
  2. +54 −0 test/to.coffee
View
@@ -21,27 +21,6 @@ describe 'fromto', ->
result.should.eql expect
fs.unlink "#{__dirname}/fromto/sample.tmp", next
- it 'Test string to stream', (next) ->
- string = """
- 20322051544,1979.0,8.8017226E7,ABC,45,2000-01-01
- 28392898392,1974.0,8.8392926E7,DEF,23,2050-11-27
- """
- csv()
- .from.string(string)
- .to.path( "#{__dirname}/fromto/string_to_stream.tmp" )
- .on 'record', (record, index) ->
- index.should.be.below 2
- if index is 0
- record[0].should.eql '20322051544'
- else if index is 1
- record[0].should.eql '28392898392'
- .on 'close', (count) ->
- count.should.eql 2
- expect = fs.readFileSync "#{__dirname}/fromto/string_to_stream.out"
- result = fs.readFileSync "#{__dirname}/fromto/string_to_stream.tmp"
- result.should.eql expect
- 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
record = [
View
@@ -0,0 +1,54 @@
+
+###
+Test CSV - Copyright David Worms <open@adaltas.com> (BSD Licensed)
+###
+
+require 'coffee-script'
+fs = require 'fs'
+should = require 'should'
+csv = if process.env.CSV_COV then require '../lib-cov/csv' else require '../src/csv'
+
+describe 'to', ->
+
+ describe 'auto', ->
+
+ it 'should write to a path', (next) ->
+ data = """
+ 20322051544,1979.0,8.8017226E7,ABC,45,2000-01-01
+ 28392898392,1974.0,8.8392926E7,DEF,23,2050-11-27
+ """
+ csv()
+ .from.string(data)
+ .to( '/tmp/csv.tmp' )
+ .on 'close', (count) ->
+ # count.should.eql 2
+ # expect = fs.readFileSync "#{__dirname}/fromto/string_to_stream.out"
+ # result = fs.readFileSync "#{__dirname}/fromto/string_to_stream.tmp"
+ # result.should.eql expect
+ console.log 'todo'
+ fs.unlink '/tmp/csv.tmp', next
+
+ describe 'path', ->
+
+ it 'Test string to stream', (next) ->
+ data = """
+ 20322051544,1979.0,8.8017226E7,ABC,45,2000-01-01
+ 28392898392,1974.0,8.8392926E7,DEF,23,2050-11-27
+ """
+ csv()
+ .from.string(data)
+ .to.path( "#{__dirname}/fromto/string_to_stream.tmp" )
+ .on 'record', (record, index) ->
+ index.should.be.below 2
+ if index is 0
+ record[0].should.eql '20322051544'
+ else if index is 1
+ record[0].should.eql '28392898392'
+ .on 'close', (count) ->
+ count.should.eql 2
+ expect = fs.readFileSync "#{__dirname}/fromto/string_to_stream.out"
+ result = fs.readFileSync "#{__dirname}/fromto/string_to_stream.tmp"
+ result.should.eql expect
+ fs.unlink "#{__dirname}/fromto/string_to_stream.tmp", next
+
+

0 comments on commit 46819a1

Please sign in to comment.