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

Commit

Permalink
columns: improve test readability
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Nov 2, 2018
1 parent cfe1d1e commit 1bded5e
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions test/options.columns.coffee
Expand Up @@ -11,7 +11,6 @@ describe 'options columns', ->
20322051544,1979,8.8017226E7,ABC,45,2000-01-01
28392898392,1974,8.8392926E7,DEF,23,2050-11-27
""", columns: true, (err, data) ->
return next err if err
data.should.eql [
"FIELD_1":"20322051544"
"FIELD_2":"1979"
Expand All @@ -26,8 +25,8 @@ describe 'options columns', ->
"FIELD_4":"DEF"
"FIELD_5":"23"
"FIELD_6":"2050-11-27"
]
next()
] unless err
next err

describe 'boolean array', ->

Expand All @@ -36,7 +35,6 @@ describe 'options columns', ->
20322051544,1979,8.8017226E7,ABC,45,2000-01-01
28392898392,1974,8.8392926E7,DEF,23,2050-11-27
""", columns: ["FIELD_1", "FIELD_2", "FIELD_3", "FIELD_4", "FIELD_5", "FIELD_6"], (err, data) ->
return next err if err
data.should.eql [
"FIELD_1":"20322051544"
"FIELD_2":"1979"
Expand All @@ -51,20 +49,19 @@ describe 'options columns', ->
"FIELD_4":"DEF"
"FIELD_5":"23"
"FIELD_6":"2050-11-27"
]
next()
] unless err
next err

it 'skip columns with false value', (next) ->
parse """
abc,123,def,456
hij,789,klm,789
""", columns: ["FIELD_1", false, "FIELD_2", false], (err, data) ->
return next err if err
data.should.eql [
{ FIELD_1: "abc", FIELD_2: "def" }
{ FIELD_1: "hij", FIELD_2: "klm"}
]
next()
] unless err
next err

it 'validate options column length on first line', (next) ->
parse """
Expand Down Expand Up @@ -92,8 +89,8 @@ describe 'options columns', ->
data.should.eql [
{a: '0', b: '4'}
{a: '5', b: '9'}
]
next()
] unless err
next err

it 'skips column names defined as false', (next) ->
parse """
Expand All @@ -103,8 +100,8 @@ describe 'options columns', ->
data.should.eql [
{a: '0', b: '4'}
{a: '5', b: '9'}
]
next()
] unless err
next err

it 'skips column names defined as null and last', (next) ->
# Fix a but where error was not throw if columns empty count was equal to
Expand All @@ -119,8 +116,8 @@ describe 'options columns', ->
data.should.eql [
{ a: '0' }
{ a: '3' }
]
next()
] unless err
next err

it 'illustrate bug with undefined values', (next) ->
# Be careful on how JavaScript handle multiple trailing commas as it
Expand All @@ -133,8 +130,8 @@ describe 'options columns', ->
data.should.eql [
{ a: '0' }
{ a: '3' }
]
next()
] unless err
next err

describe 'function', ->

Expand All @@ -147,7 +144,6 @@ describe 'options columns', ->
for column in columns
column.toLowerCase()
, (err, data) ->
return next err if err
data.should.eql [
"field_1":"20322051544"
"field_2":"1979"
Expand All @@ -162,8 +158,8 @@ describe 'options columns', ->
"field_4":"DEF"
"field_5":"23"
"field_6":"2050-11-27"
]
next()
] unless err
next err

it 'catch thrown errors', (next) ->
parse """
Expand Down

0 comments on commit 1bded5e

Please sign in to comment.