Skip to content

Commit 1dbf3bc

Browse files
Move isShutdown to state expectations (#2102)
1 parent 716bf5b commit 1dbf3bc

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

packages/firestore/test/unit/local/persistence_test_helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ export async function testMemoryLruPersistence(
144144
}
145145

146146
/** Clears the persistence in tests */
147-
export async function clearTestPersistence(): Promise<void> {
148-
await IndexedDbPersistence.clearPersistence(TEST_PERSISTENCE_PREFIX);
147+
export function clearTestPersistence(): Promise<void> {
148+
return IndexedDbPersistence.clearPersistence(TEST_PERSISTENCE_PREFIX);
149149
}
150150

151151
class NoOpSharedClientStateSyncer implements SharedClientStateSyncer {

packages/firestore/test/unit/specs/spec_builder.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,10 @@ export class SpecBuilder {
395395
}
396396

397397
expectIsShutdown(): this {
398-
this.nextStep();
399-
this.currentStep = {
400-
expectIsShutdown: true
401-
};
398+
this.assertStep('Active target expectation requires previous step');
399+
const currentStep = this.currentStep!;
400+
currentStep.stateExpect = currentStep.stateExpect || {};
401+
currentStep.stateExpect.isShutdown = true;
402402
return this;
403403
}
404404

packages/firestore/test/unit/specs/spec_test_runner.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,6 @@ abstract class TestRunner {
569569
return this.doRestart();
570570
} else if ('shutdown' in step) {
571571
return this.doShutdown();
572-
} else if ('expectIsShutdown' in step) {
573-
return this.doExpectIsShutdown();
574572
} else if ('applyClientState' in step) {
575573
// PORTING NOTE: Only used by web multi-tab tests.
576574
return this.doApplyClientState(step.applyClientState!);
@@ -885,11 +883,6 @@ abstract class TestRunner {
885883
this.started = false;
886884
}
887885

888-
/** Asserts that the client is shutdown by */
889-
private async doExpectIsShutdown(): Promise<void> {
890-
expect(this.started).to.equal(false);
891-
}
892-
893886
private async doClearPersistence(): Promise<void> {
894887
await clearTestPersistence();
895888
}
@@ -985,6 +978,9 @@ abstract class TestRunner {
985978
if ('isPrimary' in expectation) {
986979
expect(this.isPrimaryClient).to.eq(expectation.isPrimary!, 'isPrimary');
987980
}
981+
if ('isShutdown' in expectation) {
982+
expect(this.started).to.equal(!expectation.isShutdown);
983+
}
988984
}
989985

990986
if (expectation && expectation.userCallbacks) {
@@ -1396,9 +1392,6 @@ export interface SpecStep {
13961392
/** Shut down the client and close it network connection. */
13971393
shutdown?: true;
13981394

1399-
/** Assert that the firestore client is shutdown. */
1400-
expectIsShutdown?: true;
1401-
14021395
/**
14031396
* Optional list of expected events.
14041397
* If not provided, the test will fail if the step causes events to be raised.
@@ -1577,6 +1570,8 @@ export interface StateExpectation {
15771570
* Whether the instance holds the primary lease. Used in multi-client tests.
15781571
*/
15791572
isPrimary?: boolean;
1573+
/** Whether the client is shutdown. */
1574+
isShutdown?: boolean;
15801575
/**
15811576
* Current expected active targets. Verified in each step until overwritten.
15821577
*/

0 commit comments

Comments
 (0)