1+ var should = require ( 'should' ) ,
2+ converter = require ( '.././lib/converter' ) ,
3+ fs = require ( 'fs' ) ,
4+ _ = require ( 'underscore' ) ,
5+ Promise = require ( 'bluebird' ) ,
6+ async = require ( 'async' ) ;
7+
8+ var options ;
9+
10+ var json = {
11+ arrayValue : require ( './JSON/arrayValueDocs' ) ,
12+ arrayValue_specificKeys : require ( './JSON/arrayValueDocs_specificKeys' ) ,
13+ nestedJson : require ( './JSON/nestedJson' ) ,
14+ nestedJson2 : require ( './JSON/nestedJson2' ) ,
15+ nestedQuotes : require ( './JSON/nestedQuotes' ) ,
16+ noData : require ( './JSON/noData' ) ,
17+ regularJson : require ( './JSON/regularJson' ) ,
18+ singleDoc : require ( './JSON/singleDoc' ) ,
19+ sameSchemaDifferentOrdering : require ( './JSON/sameSchemaDifferentOrdering' ) ,
20+ differentSchemas : require ( './JSON/differentSchemas' )
21+ } ,
22+ csv = { } , // Document where all csv files will be loaded into
23+ csvFiles = [
24+ { key : 'arrayValue' , file : './CSV/arrayValueDocs.csv' } ,
25+ { key : 'arrayValue_specificKeys' , file : './CSV/arrayValueDocs_specificKeys.csv' } ,
26+ { key : 'nestedJson' , file : './CSV/nestedJson.csv' } ,
27+ { key : 'nestedJson2' , file : './CSV/nestedJson2.csv' } ,
28+ { key : 'nestedQuotes' , file : './CSV/nestedQuotes.csv' } ,
29+ { key : 'noData' , file : './CSV/noData.csv' } ,
30+ { key : 'regularJson' , file : './CSV/regularJson.csv' } ,
31+ { key : 'singleDoc' , file : './CSV/singleDoc.csv' }
32+ ] ;
33+
34+ var csv2jsonTests = function ( ) {
35+ describe ( 'Testing Default Usage' , function ( ) {
36+ describe ( 'Default Options' , function ( ) {
37+
38+ } ) ;
39+
40+ describe ( 'Custom Options - Comma Delimited' , function ( ) {
41+ beforeEach ( function ( ) {
42+
43+ } ) ;
44+ } ) ;
45+
46+ describe ( 'Custom Options - Semicolon Delimited' , function ( ) {
47+ beforeEach ( function ( ) {
48+ options = {
49+ DELIMITER : {
50+ FIELD : ';' ,
51+ ARRAY : '/'
52+ } ,
53+ EOL : '\n' ,
54+ PARSE_CSV_NUMBERS : false
55+ } ;
56+ } ) ;
57+ } ) ;
58+
59+ describe ( 'Custom Options - Quote Wrapped Fields' , function ( ) {
60+ beforeEach ( function ( ) {
61+
62+ } ) ;
63+ } ) ;
64+ } ) ;
65+
66+ describe ( 'Testing Promisified Usage' , function ( ) {
67+ beforeEach ( function ( ) {
68+ converter = Promise . promisifyAll ( converter ) ;
69+ } ) ;
70+
71+ describe ( 'Default Options' , function ( ) {
72+
73+ } ) ;
74+
75+ describe ( 'Custom Options - Comma Delimited' , function ( ) {
76+ beforeEach ( function ( ) {
77+
78+ } ) ;
79+ } ) ;
80+
81+ describe ( 'Custom Options - Semicolon Delimited' , function ( ) {
82+ beforeEach ( function ( ) {
83+ options = {
84+ DELIMITER : {
85+ FIELD : ';' ,
86+ ARRAY : '/'
87+ } ,
88+ EOL : '\n' ,
89+ PARSE_CSV_NUMBERS : false
90+ } ;
91+ } ) ;
92+ } ) ;
93+
94+ describe ( 'Custom Options - Quote Wrapped Fields' , function ( ) {
95+ beforeEach ( function ( ) {
96+
97+ } ) ;
98+ } ) ;
99+ } ) ;
100+ } ;
101+
102+ var readCsvFile = function ( fileInfo , callback ) {
103+ csv [ fileInfo . key ] = fs . readFileSync ( fileInfo . file ) ;
104+ return callback ( null , csv [ fileInfo . key ] ) ;
105+ } ;
106+
107+ module . exports = {
108+ runTests : function ( callback ) {
109+ describe ( 'csv2json' , function ( ) {
110+ before ( function ( done ) {
111+ async . parallel (
112+ _ . map ( csvFiles , function ( fileInfo ) { return _ . partial ( readCsvFile , fileInfo ) ; } ) ,
113+ function ( err , results ) {
114+ if ( err ) throw err ;
115+ done ( ) ;
116+ } ) ;
117+ } ) ;
118+
119+ beforeEach ( function ( ) {
120+ options = null ;
121+ } ) ;
122+
123+ // Run JSON to CSV Tests
124+ json2csvTests ( ) ;
125+ } ) ;
126+ }
127+ } ;
0 commit comments