11
22import { stringify } from ' ../lib/index.js'
3+ import { stringify as stringifySync } from ' ../lib/sync.js'
34
45describe ' Option `header`' , ->
56
@@ -64,12 +65,16 @@ describe 'Option `header`', ->
6465
6566 describe ' without records' , ->
6667
67- it ' should print headers if no records to parse' , (next ) ->
68+ it ' print headers if no records to parse' , (next ) ->
6869 stringify [], header : true , columns : [' some' , ' headers' ], (err , data ) ->
6970 data .should .eql ' some,headers\n '
7071 next ()
7172
72- it ' should not print headers if no records to parse and no header option' , (next ) ->
73+ it ' print headers if no records to parse in sync mode, fix #343' , ->
74+ data = stringifySync [], header : true , columns : [' some' , ' headers' ]
75+ data .should .eql ' some,headers\n '
76+
77+ it ' not print headers if no records to parse and no header option' , (next ) ->
7378 stringify [], header : false , columns : [' some' , ' headers' ], (err , data ) ->
7479 data .should .eql ' '
7580 next ()
@@ -100,15 +105,15 @@ describe 'Option `header`', ->
100105 """
101106 next ()
102107
103- it ' should map the column property name to display name' , (next ) ->
108+ it ' map the column property name to display name' , (next ) ->
104109 stringify [
105110 { field1 : ' val11' , field2 : ' val12' , field3 : ' val13' }
106111 { field1 : ' val21' , field2 : ' val22' , field3 : ' val23' }
107112 ], header : true , columns : {field1 : ' column1' , field3 : ' column3' }, (err , data ) ->
108113 data .should .eql ' column1,column3\n val11,val13\n val21,val23\n ' unless err
109114 next err
110115
111- it ' should map the column property name to display name' , (next ) ->
116+ it ' map the column property name to display name' , (next ) ->
112117 stringify [
113118 { field1 : ' val11' , field2 : ' val12' , field3 : ' val13' }
114119 { field1 : ' val21' , field2 : ' val22' , field3 : ' val23' }
@@ -126,7 +131,7 @@ describe 'Option `header`', ->
126131 data .should .eql ' column1,column3\n val11,val13\n ,val23\n ' unless err
127132 next err
128133
129- it ' should also work for nested properties' , (next ) ->
134+ it ' also work for nested properties' , (next ) ->
130135 stringify [
131136 { field1 : {nested : ' val11' }, field2 : ' val12' , field3 : ' val13' }
132137 { field1 : {}, field2 : ' val22' , field3 : ' val23' }
0 commit comments