@@ -190,18 +190,18 @@ describe('parse', () => {
190
190
it ( 'happy path' , ( ) => {
191
191
// arrange:
192
192
let msgNum = 0 ;
193
- const next = parse . getMessages ( id => {
194
- expect ( id ) . toEqual ( 'abc' ) ;
195
- } , retry => {
196
- expect ( retry ) . toEqual ( 42 ) ;
197
- } , msg => {
193
+ const next = parse . getMessages ( msg => {
198
194
++ msgNum ;
199
195
expect ( msg ) . toEqual ( {
200
196
retry : 42 ,
201
197
id : 'abc' ,
202
198
event : 'def' ,
203
199
data : 'ghi'
204
200
} ) ;
201
+ } , id => {
202
+ expect ( id ) . toEqual ( 'abc' ) ;
203
+ } , retry => {
204
+ expect ( retry ) . toEqual ( 42 ) ;
205
205
} ) ;
206
206
207
207
// act:
@@ -217,18 +217,18 @@ describe('parse', () => {
217
217
218
218
it ( 'skip unknown fields' , ( ) => {
219
219
let msgNum = 0 ;
220
- const next = parse . getMessages ( id => {
221
- expect ( id ) . toEqual ( 'abc' ) ;
222
- } , _retry => {
223
- fail ( 'retry should not be called' ) ;
224
- } , msg => {
220
+ const next = parse . getMessages ( msg => {
225
221
++ msgNum ;
226
222
expect ( msg ) . toEqual ( {
227
223
id : 'abc' ,
228
224
data : '' ,
229
225
event : '' ,
230
226
retry : undefined ,
231
227
} ) ;
228
+ } , id => {
229
+ expect ( id ) . toEqual ( 'abc' ) ;
230
+ } , _retry => {
231
+ fail ( 'retry should not be called' ) ;
232
232
} ) ;
233
233
234
234
// act:
@@ -242,18 +242,18 @@ describe('parse', () => {
242
242
243
243
it ( 'ignore non-integer retry' , ( ) => {
244
244
let msgNum = 0 ;
245
- const next = parse . getMessages ( _id => {
246
- fail ( 'id should not be called' ) ;
247
- } , _retry => {
248
- fail ( 'retry should not be called' ) ;
249
- } , msg => {
245
+ const next = parse . getMessages ( msg => {
250
246
++ msgNum ;
251
247
expect ( msg ) . toEqual ( {
252
248
id : '' ,
253
249
data : '' ,
254
250
event : '' ,
255
251
retry : undefined ,
256
252
} ) ;
253
+ } , _id => {
254
+ fail ( 'id should not be called' ) ;
255
+ } , _retry => {
256
+ fail ( 'retry should not be called' ) ;
257
257
} ) ;
258
258
259
259
// act:
@@ -267,18 +267,18 @@ describe('parse', () => {
267
267
it ( 'skip comment-only messages' , ( ) => {
268
268
// arrange:
269
269
let msgNum = 0 ;
270
- const next = parse . getMessages ( id => {
271
- expect ( id ) . toEqual ( '123' ) ;
272
- } , _retry => {
273
- fail ( 'retry should not be called' ) ;
274
- } , msg => {
270
+ const next = parse . getMessages ( msg => {
275
271
++ msgNum ;
276
272
expect ( msg ) . toEqual ( {
277
273
retry : undefined ,
278
274
id : '123' ,
279
275
event : 'foo ' ,
280
276
data : '' ,
281
277
} ) ;
278
+ } , id => {
279
+ expect ( id ) . toEqual ( '123' ) ;
280
+ } , _retry => {
281
+ fail ( 'retry should not be called' ) ;
282
282
} ) ;
283
283
284
284
// act:
@@ -295,18 +295,18 @@ describe('parse', () => {
295
295
it ( 'should append data split across multiple lines' , ( ) => {
296
296
// arrange:
297
297
let msgNum = 0 ;
298
- const next = parse . getMessages ( _id => {
299
- fail ( 'id should not be called' ) ;
300
- } , _retry => {
301
- fail ( 'retry should not be called' ) ;
302
- } , msg => {
298
+ const next = parse . getMessages ( msg => {
303
299
++ msgNum ;
304
300
expect ( msg ) . toEqual ( {
305
301
data : 'YHOO\n+2\n\n10' ,
306
302
id : '' ,
307
303
event : '' ,
308
304
retry : undefined ,
309
305
} ) ;
306
+ } , _id => {
307
+ fail ( 'id should not be called' ) ;
308
+ } , _retry => {
309
+ fail ( 'retry should not be called' ) ;
310
310
} ) ;
311
311
312
312
// act:
@@ -325,19 +325,19 @@ describe('parse', () => {
325
325
const expectedIds = [ 'foo' , '' ] ;
326
326
let idsIdx = 0 ;
327
327
let msgNum = 0 ;
328
- const next = parse . getMessages ( id => {
329
- expect ( id ) . toEqual ( expectedIds [ idsIdx ] ) ;
330
- ++ idsIdx ;
331
- } , _retry => {
332
- fail ( 'retry should not be called' ) ;
333
- } , msg => {
328
+ const next = parse . getMessages ( msg => {
334
329
++ msgNum ;
335
330
expect ( msg ) . toEqual ( {
336
331
data : '' ,
337
332
id : '' ,
338
333
event : '' ,
339
334
retry : undefined ,
340
335
} ) ;
336
+ } , id => {
337
+ expect ( id ) . toEqual ( expectedIds [ idsIdx ] ) ;
338
+ ++ idsIdx ;
339
+ } , _retry => {
340
+ fail ( 'retry should not be called' ) ;
341
341
} ) ;
342
342
343
343
// act:
0 commit comments