@@ -228,6 +228,20 @@ export class SyncPointTestParser {
228
228
}
229
229
}
230
230
} ;
231
+ const EVENT_ORDERING = [
232
+ 'child_removed' ,
233
+ 'child_added' ,
234
+ 'child_moved' ,
235
+ 'child_changed' ,
236
+ 'value'
237
+ ] ;
238
+ const assertEventsOrdered = function ( e1 , e2 ) {
239
+ const idx1 = EVENT_ORDERING . indexOf ( e1 ) ;
240
+ const idx2 = EVENT_ORDERING . indexOf ( e2 ) ;
241
+ if ( idx1 > idx2 ) {
242
+ throw new Error ( 'Received ' + e2 + ' after ' + e1 ) ;
243
+ }
244
+ } ;
231
245
232
246
const eventSetMatch = ( expected : any , actual : DataEvent [ ] ) => {
233
247
// don't worry about order for now
@@ -277,10 +291,28 @@ export class SyncPointTestParser {
277
291
// Step 3: slice each array
278
292
const expectedSlice = currentExpected . slice ( 0 , i ) ;
279
293
const actualSlice = currentActual . slice ( 0 , i ) ;
280
-
294
+ const actualMap = { } ;
281
295
// foreach in actual, stack up to enforce ordering, find in expected
282
296
for ( let x = 0 ; x < actualSlice . length ; ++ x ) {
283
297
const actualEvent = actualSlice [ x ] ;
298
+ actualEvent . eventRegistration . getEventRunner ( actualEvent ) ( ) ;
299
+ const spec = currentSpec ;
300
+ const listenId =
301
+ this . getTestPath ( optBasePath , spec . path ) . toString ( ) +
302
+ '|' +
303
+ spec . ref . _queryIdentifier ;
304
+ if ( listenId in actualMap ) {
305
+ // stack this event up, and make sure it obeys ordering constraints
306
+ const eventStack = actualMap [ listenId ] ;
307
+ assertEventsOrdered (
308
+ eventStack [ eventStack . length - 1 ] . eventType ,
309
+ actualEvent . eventType
310
+ ) ;
311
+ eventStack . push ( actualEvent ) ;
312
+ } else {
313
+ // this is the first event for this listen, just initialize it
314
+ actualMap [ listenId ] = [ actualEvent ] ;
315
+ }
284
316
// Ordering has been enforced, make sure we can find this in the expected events
285
317
const found = removeIf ( expectedSlice , expectedEvent => {
286
318
checkValidProperties ( expectedEvent , [
0 commit comments