/
lineBreaks.coffee
60 lines (55 loc) · 2.69 KB
/
lineBreaks.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Test CSV - Copyright David Worms <open@adaltas.com> (BSD Licensed)
fs = require 'fs'
should = require 'should'
csv = require '..'
describe 'lineBreaks', ->
it 'Test line breaks custom', ->
csv()
.fromPath( "#{__dirname}/lineBreaks/lineBreaks.in" )
.toPath( "#{__dirname}/lineBreaks/custom.tmp", lineBreaks: '::' )
.on 'end', (count) ->
count.should.eql 2
expect = fs.readFileSync( "#{__dirname}/lineBreaks/custom.out").toString()
result = fs.readFileSync( "#{__dirname}/lineBreaks/custom.tmp").toString()
result.should.eql expect
fs.unlink "#{__dirname}/lineBreaks/custom.tmp"
it 'Test line breaks unix', ->
csv()
.fromPath( "#{__dirname}/lineBreaks/lineBreaks.in" )
.toPath( "#{__dirname}/lineBreaks/unix.tmp", lineBreaks: "unix")
.on 'end', (count) ->
count.should.eql 2
expect = fs.readFileSync( "#{__dirname}/lineBreaks/unix.out" ).toString()
result = fs.readFileSync( "#{__dirname}/lineBreaks/unix.tmp" ).toString()
result.should.eql expect
fs.unlink "#{__dirname}/lineBreaks/unix.tmp"
it 'Test line breaks unicode', ->
csv()
.fromPath( "#{__dirname}/lineBreaks/lineBreaks.in")
.toPath( "#{__dirname}/lineBreaks/unicode.tmp", lineBreaks: 'unicode')
.on 'end', (count) ->
count.should.eql 2
expect = fs.readFileSync( "#{__dirname}/lineBreaks/unicode.out" ).toString()
result = fs.readFileSync( "#{__dirname}/lineBreaks/unicode.tmp" ).toString()
result.should.eql expect
fs.unlink "#{__dirname}/lineBreaks/unicode.tmp"
it 'Test line breaks mac', ->
csv()
.fromPath( "#{__dirname}/lineBreaks/lineBreaks.in" )
.toPath( "#{__dirname}/lineBreaks/mac.tmp", lineBreaks: 'mac' )
.on 'end', (count) ->
count.should.eql 2
expect = fs.readFileSync( "#{__dirname}/lineBreaks/mac.out" ).toString()
result = fs.readFileSync( "#{__dirname}/lineBreaks/mac.tmp" ).toString()
result.should.eql expect
fs.unlink "#{__dirname}/lineBreaks/mac.tmp"
it 'Test line breaks windows', ->
csv()
.fromPath( "#{__dirname}/lineBreaks/lineBreaks.in" )
.toPath( "#{__dirname}/lineBreaks/windows.tmp", lineBreaks: 'windows' )
.on 'end', (count) ->
count.should.eql 2
expect = fs.readFileSync( "#{__dirname}/lineBreaks/windows.out" ).toString()
result = fs.readFileSync( "#{__dirname}/lineBreaks/windows.tmp" ).toString()
result.should.eql expect
fs.unlink "#{__dirname}/lineBreaks/windows.tmp"