@@ -520,8 +520,8 @@ abstract class TestRunner {
520
520
async run ( step : SpecStep ) : Promise < void > {
521
521
await this . doStep ( step ) ;
522
522
await this . queue . drain ( ) ;
523
- this . validateStepExpectations ( step . expectedSnapshotEvents ! ) ;
524
- await this . validateStateExpectations ( step . expectedState ! ) ;
523
+ this . validateExpectedSnapshotEvents ( step . expectedSnapshotEvents ! ) ;
524
+ await this . validateExpectedState ( step . expectedState ! ) ;
525
525
this . validateSnapshotsInSyncEvents ( step . expectedSnapshotsInSyncEvents ) ;
526
526
this . eventList = [ ] ;
527
527
this . rejectedDocs = [ ] ;
@@ -948,16 +948,18 @@ abstract class TestRunner {
948
948
) ;
949
949
}
950
950
951
- private validateStepExpectations ( stepExpectations : SnapshotEvent [ ] ) : void {
952
- if ( stepExpectations ) {
951
+ private validateExpectedSnapshotEvents (
952
+ expectedEvents : SnapshotEvent [ ]
953
+ ) : void {
954
+ if ( expectedEvents ) {
953
955
expect ( this . eventList . length ) . to . equal (
954
- stepExpectations . length ,
956
+ expectedEvents . length ,
955
957
'Number of expected and actual events mismatch'
956
958
) ;
957
959
const actualEventsSorted = this . eventList . sort ( ( a , b ) =>
958
960
primitiveComparator ( a . query . canonicalId ( ) , b . query . canonicalId ( ) )
959
961
) ;
960
- const expectedEventsSorted = stepExpectations . sort ( ( a , b ) =>
962
+ const expectedEventsSorted = expectedEvents . sort ( ( a , b ) =>
961
963
primitiveComparator (
962
964
this . parseQuery ( a . query ) . canonicalId ( ) ,
963
965
this . parseQuery ( b . query ) . canonicalId ( )
@@ -976,49 +978,52 @@ abstract class TestRunner {
976
978
}
977
979
}
978
980
979
- private async validateStateExpectations (
980
- expectation : StateExpectation
981
+ private async validateExpectedState (
982
+ expectedState : StateExpectation
981
983
) : Promise < void > {
982
- if ( expectation ) {
983
- if ( 'numOutstandingWrites' in expectation ) {
984
+ if ( expectedState ) {
985
+ if ( 'numOutstandingWrites' in expectedState ) {
984
986
expect ( this . remoteStore . outstandingWrites ( ) ) . to . equal (
985
- expectation . numOutstandingWrites
987
+ expectedState . numOutstandingWrites
986
988
) ;
987
989
}
988
- if ( 'numActiveClients' in expectation ) {
990
+ if ( 'numActiveClients' in expectedState ) {
989
991
const activeClients = await this . persistence . getActiveClients ( ) ;
990
- expect ( activeClients . length ) . to . equal ( expectation . numActiveClients ) ;
992
+ expect ( activeClients . length ) . to . equal ( expectedState . numActiveClients ) ;
991
993
}
992
- if ( 'writeStreamRequestCount' in expectation ) {
994
+ if ( 'writeStreamRequestCount' in expectedState ) {
993
995
expect ( this . connection . writeStreamRequestCount ) . to . equal (
994
- expectation . writeStreamRequestCount
996
+ expectedState . writeStreamRequestCount
995
997
) ;
996
998
}
997
- if ( 'watchStreamRequestCount' in expectation ) {
999
+ if ( 'watchStreamRequestCount' in expectedState ) {
998
1000
expect ( this . connection . watchStreamRequestCount ) . to . equal (
999
- expectation . watchStreamRequestCount
1001
+ expectedState . watchStreamRequestCount
1000
1002
) ;
1001
1003
}
1002
- if ( 'limboDocs' in expectation ) {
1003
- this . expectedLimboDocs = expectation . limboDocs ! . map ( key ) ;
1004
+ if ( 'limboDocs' in expectedState ) {
1005
+ this . expectedLimboDocs = expectedState . limboDocs ! . map ( key ) ;
1004
1006
}
1005
- if ( 'activeTargets' in expectation ) {
1006
- this . expectedActiveTargets = expectation . activeTargets ! ;
1007
+ if ( 'activeTargets' in expectedState ) {
1008
+ this . expectedActiveTargets = expectedState . activeTargets ! ;
1007
1009
}
1008
- if ( 'isPrimary' in expectation ) {
1009
- expect ( this . isPrimaryClient ) . to . eq ( expectation . isPrimary ! , 'isPrimary' ) ;
1010
+ if ( 'isPrimary' in expectedState ) {
1011
+ expect ( this . isPrimaryClient ) . to . eq (
1012
+ expectedState . isPrimary ! ,
1013
+ 'isPrimary'
1014
+ ) ;
1010
1015
}
1011
- if ( 'isShutdown' in expectation ) {
1012
- expect ( this . started ) . to . equal ( ! expectation . isShutdown ) ;
1016
+ if ( 'isShutdown' in expectedState ) {
1017
+ expect ( this . started ) . to . equal ( ! expectedState . isShutdown ) ;
1013
1018
}
1014
1019
}
1015
1020
1016
- if ( expectation && expectation . userCallbacks ) {
1021
+ if ( expectedState && expectedState . userCallbacks ) {
1017
1022
expect ( this . acknowledgedDocs ) . to . have . members (
1018
- expectation . userCallbacks . acknowledgedDocs
1023
+ expectedState . userCallbacks . acknowledgedDocs
1019
1024
) ;
1020
1025
expect ( this . rejectedDocs ) . to . have . members (
1021
- expectation . userCallbacks . rejectedDocs
1026
+ expectedState . userCallbacks . rejectedDocs
1022
1027
) ;
1023
1028
} else {
1024
1029
expect ( this . acknowledgedDocs ) . to . be . empty ;
0 commit comments