Skip to content

Commit b49bccb

Browse files
Using forEach Helper
1 parent f36a9da commit b49bccb

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

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

+18-19
Original file line numberDiff line numberDiff line change
@@ -398,32 +398,31 @@ describe('IndexedDbSchema: createOrUpgradeDb', () => {
398398
DbMutationQueue
399399
>(DbMutationQueue.store);
400400
// Manually populate the mutation queue and create all indicies.
401-
let p = PersistencePromise.resolve();
402-
for (const testMutation of testMutations) {
403-
p = p.next(() => mutationBatchStore.put(testMutation));
404-
for (const write of testMutation.mutations) {
405-
p = p.next(() => {
406-
const indexKey = DbDocumentMutation.key(
407-
testMutation.userId,
408-
path(write.update.name, 5),
409-
testMutation.batchId
410-
);
411-
return documentMutationStore.put(
412-
indexKey,
413-
DbDocumentMutation.PLACEHOLDER
414-
);
415-
});
416-
}
417-
}
418-
p = p.next(() =>
401+
return PersistencePromise.forEach(testMutations, testMutation => {
402+
return mutationBatchStore.put(testMutation).next(() => {
403+
return PersistencePromise.forEach(
404+
testMutation.mutations,
405+
mutation => {
406+
const indexKey = DbDocumentMutation.key(
407+
testMutation.userId,
408+
path(mutation.update.name, 5),
409+
testMutation.batchId
410+
);
411+
return documentMutationStore.put(
412+
indexKey,
413+
DbDocumentMutation.PLACEHOLDER
414+
);
415+
}
416+
);
417+
});
418+
}).next(() =>
419419
// Populate the mutation queues' metadata
420420
PersistencePromise.waitFor([
421421
mutationQueuesStore.put(new DbMutationQueue('foo', 2, '')),
422422
mutationQueuesStore.put(new DbMutationQueue('bar', 3, '')),
423423
mutationQueuesStore.put(new DbMutationQueue('empty', -1, ''))
424424
])
425425
);
426-
return p;
427426
});
428427
}).then(() =>
429428
withDb(5, db => {

0 commit comments

Comments
 (0)