@@ -270,6 +270,19 @@ var json2csvTests = function () {
270
270
} , options ) ;
271
271
} ) ;
272
272
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
+
273
286
it ( 'should throw an error if the documents do not have the same schema' , function ( done ) {
274
287
converter . json2csv ( jsonTestData . differentSchemas , function ( err , csv ) {
275
288
err . message . should . equal ( constants . Errors . json2csv . notSameSchema ) ;
@@ -433,6 +446,19 @@ var json2csvTests = function () {
433
446
} , options ) ;
434
447
} ) ;
435
448
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
+
436
462
it ( 'should throw an error if the documents do not have the same schema' , function ( done ) {
437
463
converter . json2csv ( jsonTestData . differentSchemas , function ( err , csv ) {
438
464
err . message . should . equal ( constants . Errors . json2csv . notSameSchema ) ;
@@ -606,6 +632,19 @@ var json2csvTests = function () {
606
632
} , options ) ;
607
633
} ) ;
608
634
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
+
609
648
it ( 'should throw an error if the documents do not have the same schema' , function ( done ) {
610
649
converter . json2csv ( jsonTestData . differentSchemas , function ( err , csv ) {
611
650
err . message . should . equal ( constants . Errors . json2csv . notSameSchema ) ;
@@ -966,6 +1005,21 @@ var json2csvTests = function () {
966
1005
} ) ;
967
1006
} ) ;
968
1007
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
+
969
1023
it ( 'should throw an error if the documents do not have the same schema' , function ( done ) {
970
1024
converter . json2csvAsync ( jsonTestData . differentSchemas , options )
971
1025
. then ( function ( csv ) {
@@ -1123,6 +1177,21 @@ var json2csvTests = function () {
1123
1177
} ) ;
1124
1178
} ) ;
1125
1179
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
+
1126
1195
it ( 'should throw an error if the documents do not have the same schema' , function ( done ) {
1127
1196
converter . json2csvAsync ( jsonTestData . differentSchemas , options )
1128
1197
. then ( function ( csv ) {
@@ -1292,6 +1361,21 @@ var json2csvTests = function () {
1292
1361
} ) ;
1293
1362
} ) ;
1294
1363
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
+
1295
1379
it ( 'should throw an error if the documents do not have the same schema' , function ( done ) {
1296
1380
converter . json2csvAsync ( jsonTestData . differentSchemas , options )
1297
1381
. then ( function ( csv ) {
0 commit comments