Skip to content

Commit f9a9664

Browse files
committed
WIP
1 parent e9fb403 commit f9a9664

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

packages/database/test/helpers/syncpoint-util.ts

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -295,18 +295,16 @@ export class SyncPointTestParser {
295295

296296
// foreach in actual, stack up to enforce ordering, find in expected
297297
const actualMap = {};
298-
let actualEvent;
299298
for (let x = 0; x < actualSlice.length; ++x) {
300-
actualEvent = actualSlice[x];
301-
actualEvent.eventRegistration.getEventRunner(actualEvent)();
299+
let actualEvent = actualSlice[x];
302300
const spec = currentSpec;
303-
const listenId =
301+
let listenId =
304302
this.getTestPath(optBasePath, spec.path).toString() +
305303
'|' +
306304
spec.ref._queryIdentifier;
307305
if (listenId in actualMap) {
308306
// stack this event up, and make sure it obeys ordering constraints
309-
const eventStack = actualMap[listenId];
307+
let eventStack = actualMap[listenId];
310308
assertEventsOrdered(
311309
eventStack[eventStack.length - 1].eventType,
312310
actualEvent.eventType
@@ -316,39 +314,39 @@ export class SyncPointTestParser {
316314
// this is the first event for this listen, just initialize it
317315
actualMap[listenId] = [actualEvent];
318316
}
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;
317+
// Ordering has been enforced, make sure we can find this in the expected events
318+
let found = removeIf(expectedSlice, expectedEvent => {
319+
checkValidProperties(expectedEvent, [
320+
'type',
321+
'path',
322+
'name',
323+
'prevName',
324+
'data'
325+
]);
326+
if (expectedEvent.type === actualEvent.eventType) {
327+
if (expectedEvent.type !== 'value') {
328+
if (expectedEvent.name !== actualEvent.snapshot.key) {
329+
return false;
330+
}
331+
if (
332+
expectedEvent.type !== 'child_removed' &&
333+
expectedEvent.prevName !== actualEvent.prevName
334+
) {
335+
return false;
336+
}
339337
}
338+
// make sure the snapshots match
339+
let snapHash = actualEvent.snapshot._node.hash();
340+
let expectedHash = nodeFromJSON(expectedEvent.data).hash();
341+
return snapHash === expectedHash;
342+
} else {
343+
return false;
340344
}
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;
345+
});
346+
if (!found) {
347+
console.log(actualEvent);
348+
throw new Error('Could not find matching expected event');
347349
}
348-
});
349-
if (!found) {
350-
// console.log(actualEvent);
351-
throw new Error('Could not find matching expected event');
352350
}
353351
currentExpected = currentExpected.slice(i);
354352
currentActual = currentActual.slice(i);
@@ -484,6 +482,8 @@ export class SyncPointTestParser {
484482
} else {
485483
events = syncTreeApplyServerOverwrite(this.syncTree_, path, update);
486484
}
485+
console.log('spec events', spec.events);
486+
console.log('events', events);
487487
eventSetMatch(spec.events, events);
488488
} else if (spec.type === 'serverMerge') {
489489
checkValidProperties(spec, ['type', 'path', 'data', 'tag', 'events']);

0 commit comments

Comments
 (0)