Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Commit

Permalink
relax_column_count: test values without additionnal options
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Nov 2, 2018
1 parent f4309fb commit e4b6d83
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions test/options.relax_column_count.coffee
Expand Up @@ -2,8 +2,27 @@
parse = require '../src'

describe 'options relax_column_count', ->

it 'throw error by default', (next) ->
parse """
1,2,3
4,5
""", (err, data) ->
err.message.should.eql 'Number of columns is inconsistent on line 2'
next()

it 'dont throw error if true', (next) ->
parse """
1,2,3
4,5
""", relax_column_count: true, (err, data) ->
data.should.eql [
[ '1', '2', '3' ]
[ '4', '5' ]
] unless err
next err

it 'read from first row if true', (next) ->
it 'with column', (next) ->
parse """
1,2,3
4,5
Expand All @@ -14,13 +33,13 @@ describe 'options relax_column_count', ->
] unless err
next err

it 'doesnt break count and relying options like from', (next) ->
it 'with columns and from, doesnt break count and relying options like from', (next) ->
parse """
1,2,3
4,5
6,7,8
9,10
""", columns: ['a','b','c','d'], relax_column_count: true, from: 3, (err, data) ->
""", relax_column_count: true, columns: ['a','b','c','d'], from: 3, (err, data) ->
data.should.eql [
{ "a":"6", "b":"7", "c":"8" }
{ "a":"9", "b":"10" }
Expand Down

0 comments on commit e4b6d83

Please sign in to comment.