Skip to content

Commit 89d46be

Browse files
Using mutable spec runner (#1114)
1 parent b30ce32 commit 89d46be

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ describeSpec(
2828
['benchmark'],
2929
() => {
3030
specTest('Insert a new document', [], () => {
31-
let steps = spec().withGCEnabled(false);
31+
const steps = spec().withGCEnabled(false);
3232
for (let i = 0; i < STEP_COUNT; ++i) {
33-
steps = steps
33+
steps
3434
.userSets(`collection/{i}`, { doc: i })
3535
.writeAcks(`collection/{i}`, i);
3636
}
@@ -42,7 +42,7 @@ describeSpec(
4242
[],
4343
() => {
4444
let currentVersion = 1;
45-
let steps = spec().withGCEnabled(false);
45+
const steps = spec().withGCEnabled(false);
4646

4747
for (let i = 0; i < STEP_COUNT; ++i) {
4848
const query = Query.atPath(path(`collection/${i}`));
@@ -56,7 +56,7 @@ describeSpec(
5656
doc: i
5757
});
5858

59-
steps = steps
59+
steps
6060
.userListens(query)
6161
.userSets(`collection/${i}`, { doc: i })
6262
.expectEvents(query, {
@@ -78,9 +78,7 @@ describeSpec(
7878
const cachedDocumentCount = 100;
7979

8080
const query = Query.atPath(path(`collection`)).addOrderBy(orderBy('v'));
81-
82-
let steps = spec().withGCEnabled(false);
83-
81+
const steps = spec().withGCEnabled(false);
8482
const docs = [];
8583

8684
for (let i = 0; i < cachedDocumentCount; ++i) {
@@ -91,7 +89,7 @@ describeSpec(
9189
}
9290

9391
for (let i = 1; i <= STEP_COUNT; ++i) {
94-
steps = steps
92+
steps
9593
.userListens(query)
9694
.expectEvents(query, {
9795
added: docs,
@@ -105,10 +103,12 @@ describeSpec(
105103
});
106104

107105
specTest('Update a single document', [], () => {
108-
let steps = spec().withGCEnabled(false);
109-
steps = steps.userSets(`collection/doc`, { v: 0 });
106+
const steps = spec()
107+
.withGCEnabled(false)
108+
.userSets(`collection/doc`, { v: 0 });
109+
110110
for (let i = 1; i <= STEP_COUNT; ++i) {
111-
steps = steps
111+
steps
112112
.userPatches(`collection/doc`, { v: i })
113113
.writeAcks(`collection/doc`, i);
114114
}
@@ -122,7 +122,7 @@ describeSpec(
122122
const query = Query.atPath(path(`collection/doc`));
123123

124124
let currentVersion = 1;
125-
let steps = spec().withGCEnabled(false);
125+
const steps = spec().withGCEnabled(false);
126126

127127
let docLocal = doc(
128128
`collection/doc`,
@@ -133,7 +133,7 @@ describeSpec(
133133
let docRemote = doc(`collection/doc`, ++currentVersion, { v: 0 });
134134
let lastRemoteVersion = currentVersion;
135135

136-
steps = steps
136+
steps
137137
.userListens(query)
138138
.userSets(`collection/doc`, { v: 0 })
139139
.expectEvents(query, {
@@ -155,7 +155,7 @@ describeSpec(
155155
docRemote = doc(`collection/doc`, ++currentVersion, { v: i });
156156
lastRemoteVersion = currentVersion;
157157

158-
steps = steps
158+
steps
159159
.userPatches(`collection/doc`, { v: i })
160160
.expectEvents(query, {
161161
modified: [docLocal],
@@ -177,11 +177,11 @@ describeSpec(
177177
const documentsPerStep = 100;
178178

179179
const query = Query.atPath(path(`collection`)).addOrderBy(orderBy('v'));
180+
const steps = spec().withGCEnabled(false);
180181

181182
let currentVersion = 1;
182-
let steps = spec().withGCEnabled(false);
183183

184-
steps = steps
184+
steps
185185
.userListens(query)
186186
.watchAcksFull(query, currentVersion)
187187
.expectEvents(query, {});
@@ -197,7 +197,7 @@ describeSpec(
197197

198198
const changeType = i === 1 ? 'added' : 'modified';
199199

200-
steps = steps
200+
steps
201201
.watchSends({ affects: [query] }, ...docs)
202202
.watchSnapshots(++currentVersion)
203203
.expectEvents(query, { [changeType]: docs });
@@ -214,7 +214,7 @@ describeSpec(
214214
const documentsPerStep = 100;
215215

216216
let currentVersion = 1;
217-
let steps = spec().withGCEnabled(false);
217+
const steps = spec().withGCEnabled(false);
218218

219219
for (let i = 1; i <= STEP_COUNT; ++i) {
220220
const collPath = `collection/${i}/coll`;
@@ -225,7 +225,7 @@ describeSpec(
225225
docs.push(doc(`${collPath}/${j}`, ++currentVersion, { v: j }));
226226
}
227227

228-
steps = steps
228+
steps
229229
.userListens(query)
230230
.watchAcksFull(query, ++currentVersion, ...docs)
231231
.expectEvents(query, { added: docs })
@@ -247,7 +247,7 @@ describeSpec(
247247
const queriesPerStep = 25;
248248

249249
let currentVersion = 1;
250-
let steps = spec().withGCEnabled(false);
250+
const steps = spec().withGCEnabled(false);
251251

252252
for (let i = 1; i <= STEP_COUNT; ++i) {
253253
// We use a different subcollection for each iteration to ensure
@@ -266,24 +266,24 @@ describeSpec(
266266
filter('val', '<=', j)
267267
);
268268
queries.push(query);
269-
steps = steps.userListens(query).watchAcks(query);
269+
steps.userListens(query).watchAcks(query);
270270
}
271271

272-
steps = steps
272+
steps
273273
.watchSends({ affects: queries }, matchingDoc)
274274
.watchSnapshots(++currentVersion);
275275

276276
// Registers the snapshot expectations with the spec runner.
277277
for (const query of queries) {
278-
steps = steps.expectEvents(query, {
278+
steps.expectEvents(query, {
279279
added: [matchingDoc],
280280
fromCache: true
281281
});
282282
}
283283

284284
// Unlisten and clean up the query.
285285
for (const query of queries) {
286-
steps = steps.userUnlistens(query).watchRemoves(query);
286+
steps.userUnlistens(query).watchRemoves(query);
287287
}
288288
}
289289

0 commit comments

Comments
 (0)