@@ -229,22 +229,7 @@ export class SyncPointTestParser {
229
229
}
230
230
} ;
231
231
232
- const EVENT_ORDERING = [
233
- 'child_removed' ,
234
- 'child_added' ,
235
- 'child_moved' ,
236
- 'child_changed' ,
237
- 'value'
238
- ] ;
239
- const assertEventsOrdered = function ( e1 , e2 ) {
240
- const idx1 = EVENT_ORDERING . indexOf ( e1 ) ;
241
- const idx2 = EVENT_ORDERING . indexOf ( e2 ) ;
242
- if ( idx1 > idx2 ) {
243
- throw new Error ( 'Received ' + e2 + ' after ' + e1 ) ;
244
- }
245
- } ;
246
-
247
- const eventSetMatch = ( expected , actual ) => {
232
+ const eventSetMatch = ( expected : any , actual : DataEvent [ ] ) => {
248
233
// don't worry about order for now
249
234
if ( expected . length !== actual . length ) {
250
235
throw new Error ( 'Mismatched lengths' ) ;
@@ -294,28 +279,10 @@ export class SyncPointTestParser {
294
279
const actualSlice = currentActual . slice ( 0 , i ) ;
295
280
296
281
// foreach in actual, stack up to enforce ordering, find in expected
297
- const actualMap = { } ;
298
282
for ( let x = 0 ; x < actualSlice . length ; ++ x ) {
299
- let actualEvent = actualSlice [ x ] ;
300
- const spec = currentSpec ;
301
- let listenId =
302
- this . getTestPath ( optBasePath , spec . path ) . toString ( ) +
303
- '|' +
304
- spec . ref . _queryIdentifier ;
305
- if ( listenId in actualMap ) {
306
- // stack this event up, and make sure it obeys ordering constraints
307
- let eventStack = actualMap [ listenId ] ;
308
- assertEventsOrdered (
309
- eventStack [ eventStack . length - 1 ] . eventType ,
310
- actualEvent . eventType
311
- ) ;
312
- eventStack . push ( actualEvent ) ;
313
- } else {
314
- // this is the first event for this listen, just initialize it
315
- actualMap [ listenId ] = [ actualEvent ] ;
316
- }
283
+ const actualEvent = actualSlice [ x ] ;
317
284
// Ordering has been enforced, make sure we can find this in the expected events
318
- let found = removeIf ( expectedSlice , expectedEvent => {
285
+ const found = removeIf ( expectedSlice , expectedEvent => {
319
286
checkValidProperties ( expectedEvent , [
320
287
'type' ,
321
288
'path' ,
@@ -336,15 +303,14 @@ export class SyncPointTestParser {
336
303
}
337
304
}
338
305
// make sure the snapshots match
339
- let snapHash = actualEvent . snapshot . _node . hash ( ) ;
340
- let expectedHash = nodeFromJSON ( expectedEvent . data ) . hash ( ) ;
306
+ const snapHash = actualEvent . snapshot . _node . hash ( ) ;
307
+ const expectedHash = nodeFromJSON ( expectedEvent . data ) . hash ( ) ;
341
308
return snapHash === expectedHash ;
342
309
} else {
343
310
return false ;
344
311
}
345
312
} ) ;
346
313
if ( ! found ) {
347
- console . log ( actualEvent ) ;
348
314
throw new Error ( 'Could not find matching expected event' ) ;
349
315
}
350
316
}
@@ -482,8 +448,6 @@ export class SyncPointTestParser {
482
448
} else {
483
449
events = syncTreeApplyServerOverwrite ( this . syncTree_ , path , update ) ;
484
450
}
485
- console . log ( 'spec events' , spec . events ) ;
486
- console . log ( 'events' , events ) ;
487
451
eventSetMatch ( spec . events , events ) ;
488
452
} else if ( spec . type === 'serverMerge' ) {
489
453
checkValidProperties ( spec , [ 'type' , 'path' , 'data' , 'tag' , 'events' ] ) ;
0 commit comments