Skip to content

Commit 5cb415c

Browse files
Using forEach Helper
1 parent f36a9da commit 5cb415c

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -398,23 +398,24 @@ 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-
}
401+
let p = 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+
});
418419
p = p.next(() =>
419420
// Populate the mutation queues' metadata
420421
PersistencePromise.waitFor([

0 commit comments

Comments
 (0)