@@ -19,6 +19,49 @@ describe('CSV Read component', async () => {
19
19
. times ( 10 )
20
20
. replyWithFile ( 200 , `${ __dirname } /../test/formats.csv` ) ;
21
21
22
+ // Previously "Fetch All" was true and "Emit Individually" was false
23
+ // The next two tests check that this backwards compatability is preserved.
24
+ describe ( 'Backwards compatibility check' , async ( ) => {
25
+ it ( 'Fetch All' , async ( ) => {
26
+ msg . body = {
27
+ url : 'http://test.env.mock/formats.csv' ,
28
+ header : true ,
29
+ dynamicTyping : true ,
30
+ delimiter : '' ,
31
+ } ;
32
+ cfg = {
33
+ emitAll : 'true' ,
34
+ } ;
35
+ context . emit = sinon . spy ( ) ;
36
+ await readCSV . process . call ( context , msg , cfg ) ;
37
+
38
+ expect ( context . emit . callCount )
39
+ . to . equal ( 1 ) ; // one emit call
40
+
41
+ expect ( context . emit . lastCall . firstArg )
42
+ . to . equal ( 'data' ) ; // with data
43
+ } ) ;
44
+
45
+ it ( 'emitAll: false, header: false, dynamicTyping: false' , async ( ) => {
46
+ msg . body = {
47
+ url : 'http://test.env.mock/formats.csv' ,
48
+ header : false ,
49
+ dynamicTyping : false ,
50
+ } ;
51
+ cfg = {
52
+ emitAll : 'false' ,
53
+ } ;
54
+ context . emit = sinon . spy ( ) ;
55
+ await readCSV . process . call ( context , msg , cfg ) ;
56
+
57
+ expect ( context . emit . callCount )
58
+ . to . equal ( 3 ) ; // 3 emit calls
59
+
60
+ expect ( context . emit . getCall ( 1 ) . args [ 1 ] . body . column0 )
61
+ . to . equal ( '2.71828' ) ; // result is number as string
62
+ } ) ;
63
+ } ) ;
64
+
22
65
it ( 'One file' , async ( ) => {
23
66
msg . body = {
24
67
url : 'http://test.env.mock/formats.csv' ,
@@ -27,7 +70,7 @@ describe('CSV Read component', async () => {
27
70
delimiter : '' ,
28
71
} ;
29
72
cfg = {
30
- emitBehavior : 'fetchAll' ,
73
+ emitAll : 'fetchAll' ,
31
74
} ;
32
75
context . emit = sinon . spy ( ) ;
33
76
await readCSV . process . call ( context , msg , cfg ) ;
@@ -39,14 +82,14 @@ describe('CSV Read component', async () => {
39
82
. to . equal ( 'data' ) ; // with data
40
83
} ) ;
41
84
42
- it ( 'emitAll: true , header: true, dynamicTyping: true' , async ( ) => {
85
+ it ( 'emitAll: fetchAll , header: true, dynamicTyping: true' , async ( ) => {
43
86
msg . body = {
44
87
url : 'http://test.env.mock/formats.csv' ,
45
88
header : true ,
46
89
dynamicTyping : true ,
47
90
} ;
48
91
cfg = {
49
- emitBehavior : 'fetchAll' ,
92
+ emitAll : 'fetchAll' ,
50
93
} ;
51
94
context . emit = sinon . spy ( ) ;
52
95
await readCSV . process . call ( context , msg , cfg ) ;
@@ -72,7 +115,7 @@ describe('CSV Read component', async () => {
72
115
batchSize : 1 ,
73
116
} ;
74
117
cfg = {
75
- emitBehavior : 'emitBatch' ,
118
+ emitAll : 'emitBatch' ,
76
119
} ;
77
120
context . emit = sinon . spy ( ) ;
78
121
await readCSV . process . call ( context , msg , cfg ) ;
@@ -90,14 +133,14 @@ describe('CSV Read component', async () => {
90
133
. to . equal ( 2.71828 ) ; // Number
91
134
} ) ;
92
135
93
- it ( 'emitAll: false , header: false, dynamicTyping: false' , async ( ) => {
136
+ it ( 'emitAll: emitIndividually , header: false, dynamicTyping: false' , async ( ) => {
94
137
msg . body = {
95
138
url : 'http://test.env.mock/formats.csv' ,
96
139
header : false ,
97
140
dynamicTyping : false ,
98
141
} ;
99
142
cfg = {
100
- emitBehavior : 'emitIndividually' ,
143
+ emitAll : 'emitIndividually' ,
101
144
} ;
102
145
context . emit = sinon . spy ( ) ;
103
146
await readCSV . process . call ( context , msg , cfg ) ;
@@ -126,7 +169,7 @@ describe('CSV Read component', async () => {
126
169
header : true ,
127
170
} ;
128
171
cfg = {
129
- emitBehavior : 'fetchAll' ,
172
+ emitAll : 'fetchAll' ,
130
173
} ;
131
174
context . emit = sinon . spy ( ) ;
132
175
await readCSV . process . call ( context , msg , cfg ) ;
@@ -140,7 +183,7 @@ describe('CSV Read component', async () => {
140
183
header : 'asd' ,
141
184
} ;
142
185
cfg = {
143
- emitBehavior : 'fetchAll' ,
186
+ emitAll : 'fetchAll' ,
144
187
} ;
145
188
context . emit = sinon . spy ( ) ;
146
189
await readCSV . process . call ( context , msg , cfg ) ;
@@ -154,7 +197,7 @@ describe('CSV Read component', async () => {
154
197
dynamicTyping : 'asd' ,
155
198
} ;
156
199
cfg = {
157
- emitBehavior : 'fetchAll' ,
200
+ emitAll : 'fetchAll' ,
158
201
} ;
159
202
context . emit = sinon . spy ( ) ;
160
203
await readCSV . process . call ( context , msg , cfg ) ;
0 commit comments