@@ -270,6 +270,19 @@ var json2csvTests = function () {
270270 } , options ) ;
271271 } ) ;
272272
273+ it ( 'should repress the heading' , function ( done ) {
274+ opts = JSON . parse ( JSON . stringify ( options ) ) ;
275+ opts . PREPEND_HEADER = false ;
276+
277+ converter . json2csv ( jsonTestData . sameSchemaDifferentOrdering , function ( err , csv ) {
278+ if ( err ) { throw err ; }
279+ true . should . equal ( _ . isEqual ( err , null ) ) ;
280+ csv . should . equal ( csvTestData . unQuoted . regularJson . split ( options . EOL ) . slice ( 1 ) . join ( options . EOL ) ) ;
281+ csv . split ( options . EOL ) . length . should . equal ( 5 ) ;
282+ done ( ) ;
283+ } , opts ) ;
284+ } ) ;
285+
273286 it ( 'should throw an error if the documents do not have the same schema' , function ( done ) {
274287 converter . json2csv ( jsonTestData . differentSchemas , function ( err , csv ) {
275288 err . message . should . equal ( constants . Errors . json2csv . notSameSchema ) ;
@@ -433,6 +446,19 @@ var json2csvTests = function () {
433446 } , options ) ;
434447 } ) ;
435448
449+ it ( 'should repress the heading' , function ( done ) {
450+ opts = JSON . parse ( JSON . stringify ( options ) ) ;
451+ opts . PREPEND_HEADER = false ;
452+
453+ converter . json2csv ( jsonTestData . sameSchemaDifferentOrdering , function ( err , csv ) {
454+ if ( err ) { throw err ; }
455+ true . should . equal ( _ . isEqual ( err , null ) ) ;
456+ csv . should . equal ( csvTestData . unQuoted . regularJson . replace ( / , / g, options . DELIMITER . FIELD ) . split ( options . EOL ) . slice ( 1 ) . join ( options . EOL ) ) ;
457+ csv . split ( options . EOL ) . length . should . equal ( 5 ) ;
458+ done ( ) ;
459+ } , opts ) ;
460+ } ) ;
461+
436462 it ( 'should throw an error if the documents do not have the same schema' , function ( done ) {
437463 converter . json2csv ( jsonTestData . differentSchemas , function ( err , csv ) {
438464 err . message . should . equal ( constants . Errors . json2csv . notSameSchema ) ;
@@ -606,6 +632,19 @@ var json2csvTests = function () {
606632 } , options ) ;
607633 } ) ;
608634
635+ it ( 'should repress the heading' , function ( done ) {
636+ opts = JSON . parse ( JSON . stringify ( options ) ) ;
637+ opts . PREPEND_HEADER = false ;
638+
639+ converter . json2csv ( jsonTestData . sameSchemaDifferentOrdering , function ( err , csv ) {
640+ if ( err ) { throw err ; }
641+ true . should . equal ( _ . isEqual ( err , null ) ) ;
642+ csv . should . equal ( csvTestData . quoted . regularJson . split ( options . EOL ) . slice ( 1 ) . join ( options . EOL ) ) ;
643+ csv . split ( options . EOL ) . length . should . equal ( 5 ) ;
644+ done ( ) ;
645+ } , opts ) ;
646+ } ) ;
647+
609648 it ( 'should throw an error if the documents do not have the same schema' , function ( done ) {
610649 converter . json2csv ( jsonTestData . differentSchemas , function ( err , csv ) {
611650 err . message . should . equal ( constants . Errors . json2csv . notSameSchema ) ;
@@ -966,6 +1005,21 @@ var json2csvTests = function () {
9661005 } ) ;
9671006 } ) ;
9681007
1008+ it ( 'should repress the heading' , function ( done ) {
1009+ opts = JSON . parse ( JSON . stringify ( options ) ) ;
1010+ opts . PREPEND_HEADER = false ;
1011+
1012+ converter . json2csvAsync ( jsonTestData . sameSchemaDifferentOrdering , opts )
1013+ . then ( function ( csv ) {
1014+ csv . should . equal ( csvTestData . unQuoted . regularJson . split ( options . EOL ) . slice ( 1 ) . join ( options . EOL ) ) ;
1015+ csv . split ( options . EOL ) . length . should . equal ( 5 ) ;
1016+ done ( ) ;
1017+ } )
1018+ . catch ( function ( err ) {
1019+ throw err ;
1020+ } ) ;
1021+ } ) ;
1022+
9691023 it ( 'should throw an error if the documents do not have the same schema' , function ( done ) {
9701024 converter . json2csvAsync ( jsonTestData . differentSchemas , options )
9711025 . then ( function ( csv ) {
@@ -1123,6 +1177,21 @@ var json2csvTests = function () {
11231177 } ) ;
11241178 } ) ;
11251179
1180+ it ( 'should repress the heading' , function ( done ) {
1181+ opts = JSON . parse ( JSON . stringify ( options ) ) ;
1182+ opts . PREPEND_HEADER = false ;
1183+
1184+ converter . json2csvAsync ( jsonTestData . sameSchemaDifferentOrdering , opts )
1185+ . then ( function ( csv ) {
1186+ csv . should . equal ( csvTestData . unQuoted . regularJson . replace ( / , / g, options . DELIMITER . FIELD ) . split ( options . EOL ) . slice ( 1 ) . join ( options . EOL ) ) ;
1187+ csv . split ( options . EOL ) . length . should . equal ( 5 ) ;
1188+ done ( ) ;
1189+ } )
1190+ . catch ( function ( err ) {
1191+ throw err ;
1192+ } ) ;
1193+ } ) ;
1194+
11261195 it ( 'should throw an error if the documents do not have the same schema' , function ( done ) {
11271196 converter . json2csvAsync ( jsonTestData . differentSchemas , options )
11281197 . then ( function ( csv ) {
@@ -1292,6 +1361,21 @@ var json2csvTests = function () {
12921361 } ) ;
12931362 } ) ;
12941363
1364+ it ( 'should repress the heading' , function ( done ) {
1365+ opts = JSON . parse ( JSON . stringify ( options ) ) ;
1366+ opts . PREPEND_HEADER = false ;
1367+
1368+ converter . json2csvAsync ( jsonTestData . sameSchemaDifferentOrdering , opts )
1369+ . then ( function ( csv ) {
1370+ csv . should . equal ( csvTestData . quoted . regularJson . split ( options . EOL ) . slice ( 1 ) . join ( options . EOL ) ) ;
1371+ csv . split ( options . EOL ) . length . should . equal ( 5 ) ;
1372+ done ( ) ;
1373+ } )
1374+ . catch ( function ( err ) {
1375+ throw err ;
1376+ } ) ;
1377+ } ) ;
1378+
12951379 it ( 'should throw an error if the documents do not have the same schema' , function ( done ) {
12961380 converter . json2csvAsync ( jsonTestData . differentSchemas , options )
12971381 . then ( function ( csv ) {
0 commit comments