@@ -228,7 +228,6 @@ export class SyncPointTestParser {
228228 }
229229 }
230230 } ;
231-
232231 const EVENT_ORDERING = [
233232 'child_removed' ,
234233 'child_added' ,
@@ -244,7 +243,7 @@ export class SyncPointTestParser {
244243 }
245244 } ;
246245
247- const eventSetMatch = ( expected , actual ) => {
246+ const eventSetMatch = ( expected : any , actual : DataEvent [ ] ) => {
248247 // don't worry about order for now
249248 if ( expected . length !== actual . length ) {
250249 throw new Error ( 'Mismatched lengths' ) ;
@@ -292,12 +291,10 @@ export class SyncPointTestParser {
292291 // Step 3: slice each array
293292 const expectedSlice = currentExpected . slice ( 0 , i ) ;
294293 const actualSlice = currentActual . slice ( 0 , i ) ;
295-
296- // foreach in actual, stack up to enforce ordering, find in expected
297294 const actualMap = { } ;
298- let actualEvent ;
295+ // foreach in actual, stack up to enforce ordering, find in expected
299296 for ( let x = 0 ; x < actualSlice . length ; ++ x ) {
300- actualEvent = actualSlice [ x ] ;
297+ const actualEvent = actualSlice [ x ] ;
301298 actualEvent . eventRegistration . getEventRunner ( actualEvent ) ( ) ;
302299 const spec = currentSpec ;
303300 const listenId =
@@ -316,39 +313,38 @@ export class SyncPointTestParser {
316313 // this is the first event for this listen, just initialize it
317314 actualMap [ listenId ] = [ actualEvent ] ;
318315 }
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+ }
339336 }
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 ;
340343 }
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' ) ;
347347 }
348- } ) ;
349- if ( ! found ) {
350- // console.log(actualEvent);
351- throw new Error ( 'Could not find matching expected event' ) ;
352348 }
353349 currentExpected = currentExpected . slice ( i ) ;
354350 currentActual = currentActual . slice ( i ) ;
0 commit comments