Skip to content

Commit e5d7003

Browse files
Fix spec tests
1 parent 340217f commit e5d7003

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import { FieldFilter, Filter, Query } from '../../../src/core/query';
1919
import { Target } from '../../../src/core/target';
20-
import { TargetIdGenerator } from '../../../src/core/target_id_generator';
2120
import { TargetId } from '../../../src/core/types';
2221
import {
2322
Document,
@@ -82,8 +81,7 @@ export class ClientMemoryState {
8281
activeTargets: ActiveTargetMap = {};
8382
queryMapping = new ObjectMap<Target, TargetId>(t => t.canonicalId());
8483
limboMapping: LimboMap = {};
85-
86-
limboIdGenerator: TargetIdGenerator = TargetIdGenerator.forSyncEngine();
84+
highestLimboTargetId = 0;
8785

8886
constructor() {
8987
this.reset();
@@ -94,7 +92,12 @@ export class ClientMemoryState {
9492
this.queryMapping = new ObjectMap<Target, TargetId>(t => t.canonicalId());
9593
this.limboMapping = {};
9694
this.activeTargets = {};
97-
this.limboIdGenerator = TargetIdGenerator.forSyncEngine();
95+
this.highestLimboTargetId = 0;
96+
}
97+
98+
nextLimboTargetId() {
99+
this.highestLimboTargetId += 2;
100+
return this.highestLimboTargetId;
98101
}
99102

100103
/**
@@ -112,7 +115,7 @@ export class ClientMemoryState {
112115
class CachedTargetIdGenerator {
113116
// TODO(wuandy): rename this to targetMapping.
114117
private queryMapping = new ObjectMap<Target, TargetId>(t => t.canonicalId());
115-
private targetIdGenerator = TargetIdGenerator.forTargetCache();
118+
private nextTargetId = 1;
116119

117120
/**
118121
* Returns a cached target ID for the provided Target, or a new ID if no
@@ -122,7 +125,8 @@ class CachedTargetIdGenerator {
122125
if (this.queryMapping.has(target)) {
123126
return this.queryMapping.get(target)!;
124127
}
125-
const targetId = this.targetIdGenerator.next();
128+
const targetId = this.nextTargetId;
129+
this.nextTargetId += 2;
126130
this.queryMapping.set(target, targetId);
127131
return targetId;
128132
}
@@ -170,8 +174,8 @@ export class SpecBuilder {
170174
return this.currentClientState;
171175
}
172176

173-
private get limboIdGenerator(): TargetIdGenerator {
174-
return this.clientState.limboIdGenerator;
177+
private nextLimboTargetId(): TargetId {
178+
return this.clientState.nextLimboTargetId();
175179
}
176180

177181
private get queryMapping(): ObjectMap<Target, TargetId> {
@@ -450,7 +454,7 @@ export class SpecBuilder {
450454
const path = key.path.canonicalString();
451455
// Create limbo target ID mapping if it was not in limbo yet
452456
if (!objUtils.contains(this.limboMapping, path)) {
453-
this.limboMapping[path] = this.limboIdGenerator.next();
457+
this.limboMapping[path] = this.nextLimboTargetId();
454458
}
455459
// Limbo doc queries are always without resume token
456460
this.addQueryToActiveTargets(

0 commit comments

Comments
 (0)