@@ -228,7 +228,6 @@ export class SyncPointTestParser {
228
228
}
229
229
}
230
230
} ;
231
-
232
231
const EVENT_ORDERING = [
233
232
'child_removed' ,
234
233
'child_added' ,
@@ -244,7 +243,7 @@ export class SyncPointTestParser {
244
243
}
245
244
} ;
246
245
247
- const eventSetMatch = ( expected , actual ) => {
246
+ const eventSetMatch = ( expected : any , actual : DataEvent [ ] ) => {
248
247
// don't worry about order for now
249
248
if ( expected . length !== actual . length ) {
250
249
throw new Error ( 'Mismatched lengths' ) ;
@@ -292,12 +291,10 @@ export class SyncPointTestParser {
292
291
// Step 3: slice each array
293
292
const expectedSlice = currentExpected . slice ( 0 , i ) ;
294
293
const actualSlice = currentActual . slice ( 0 , i ) ;
295
-
296
- // foreach in actual, stack up to enforce ordering, find in expected
297
294
const actualMap = { } ;
298
- let actualEvent ;
295
+ // foreach in actual, stack up to enforce ordering, find in expected
299
296
for ( let x = 0 ; x < actualSlice . length ; ++ x ) {
300
- actualEvent = actualSlice [ x ] ;
297
+ const actualEvent = actualSlice [ x ] ;
301
298
actualEvent . eventRegistration . getEventRunner ( actualEvent ) ( ) ;
302
299
const spec = currentSpec ;
303
300
const listenId =
@@ -316,39 +313,38 @@ export class SyncPointTestParser {
316
313
// this is the first event for this listen, just initialize it
317
314
actualMap [ listenId ] = [ actualEvent ] ;
318
315
}
319
- }
320
- // Ordering has been enforced, make sure we can find this in the expected events
321
- const found = removeIf ( expectedSlice , expectedEvent => {
322
- checkValidProperties ( expectedEvent , [
323
- 'type ',
324
- 'path ',
325
- 'name ',
326
- 'prevName' ,
327
- 'data'
328
- ] ) ;
329
- if ( expectedEvent . type === actualEvent . eventType ) {
330
- if ( expectedEvent . type !== 'value' ) {
331
- if ( expectedEvent . name !== actualEvent . snapshot . key ) {
332
- return false ;
333
- }
334
- if (
335
- expectedEvent . type !== 'child_removed' &&
336
- expectedEvent . prevName !== actualEvent . prevName
337
- ) {
338
- return false ;
316
+ // Ordering has been enforced, make sure we can find this in the expected events
317
+ const found = removeIf ( expectedSlice , expectedEvent => {
318
+ checkValidProperties ( expectedEvent , [
319
+ 'type' ,
320
+ 'path ',
321
+ 'name ',
322
+ 'prevName ',
323
+ 'data'
324
+ ] ) ;
325
+ if ( expectedEvent . type === actualEvent . eventType ) {
326
+ if ( expectedEvent . type !== 'value' ) {
327
+ if ( expectedEvent . name !== actualEvent . snapshot . key ) {
328
+ return false ;
329
+ }
330
+ if (
331
+ expectedEvent . type !== 'child_removed' &&
332
+ expectedEvent . prevName !== actualEvent . prevName
333
+ ) {
334
+ return false ;
335
+ }
339
336
}
337
+ // make sure the snapshots match
338
+ const snapHash = actualEvent . snapshot . _node . hash ( ) ;
339
+ const expectedHash = nodeFromJSON ( expectedEvent . data ) . hash ( ) ;
340
+ return snapHash === expectedHash ;
341
+ } else {
342
+ return false ;
340
343
}
341
- // make sure the snapshots match
342
- const snapHash = actualEvent . snapshot . _node . hash ( ) ;
343
- const expectedHash = nodeFromJSON ( expectedEvent . data ) . hash ( ) ;
344
- return snapHash === expectedHash ;
345
- } else {
346
- return false ;
344
+ } ) ;
345
+ if ( ! found ) {
346
+ throw new Error ( 'Could not find matching expected event' ) ;
347
347
}
348
- } ) ;
349
- if ( ! found ) {
350
- // console.log(actualEvent);
351
- throw new Error ( 'Could not find matching expected event' ) ;
352
348
}
353
349
currentExpected = currentExpected . slice ( i ) ;
354
350
currentActual = currentActual . slice ( i ) ;
0 commit comments