Skip to content

Commit f2159b9

Browse files
Add hasCommittedMutations to NoDocument equals (#1245)
1 parent 5ca119a commit f2159b9

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

packages/firestore/src/model/document.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export class NoDocument extends MaybeDocument {
141141
isEqual(other: MaybeDocument | null | undefined): boolean {
142142
return (
143143
other instanceof NoDocument &&
144+
other.hasCommittedMutations === this.hasCommittedMutations &&
144145
other.version.isEqual(this.version) &&
145146
other.key.isEqual(this.key)
146147
);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ function genericLocalStoreTests(
531531
.toContain(deletedDoc('foo/bar', 0))
532532
.afterAcknowledgingMutation({ documentVersion: 1 })
533533
.toReturnRemoved('foo/bar')
534-
.toContain(deletedDoc('foo/bar', 1))
534+
.toContain(deletedDoc('foo/bar', 1, { hasCommittedMutations: true }))
535535
.finish();
536536
});
537537

@@ -551,7 +551,7 @@ function genericLocalStoreTests(
551551
.afterReleasingQuery(query)
552552
.afterAcknowledgingMutation({ documentVersion: 2 })
553553
.toReturnRemoved('foo/bar')
554-
.toContain(deletedDoc('foo/bar', 2))
554+
.toContain(deletedDoc('foo/bar', 2, { hasCommittedMutations: true }))
555555
.finish()
556556
);
557557
});
@@ -572,7 +572,7 @@ function genericLocalStoreTests(
572572
.afterReleasingQuery(query)
573573
.afterAcknowledgingMutation({ documentVersion: 2 })
574574
.toReturnRemoved('foo/bar')
575-
.toContain(deletedDoc('foo/bar', 2))
575+
.toContain(deletedDoc('foo/bar', 2, { hasCommittedMutations: true }))
576576
.finish()
577577
);
578578
});
@@ -685,7 +685,7 @@ function genericLocalStoreTests(
685685
.toContain(deletedDoc('foo/bar', 0))
686686
.afterAcknowledgingMutation({ documentVersion: 2 }) // delete mutation
687687
.toReturnRemoved('foo/bar')
688-
.toContain(deletedDoc('foo/bar', 2))
688+
.toContain(deletedDoc('foo/bar', 2, { hasCommittedMutations: true }))
689689
.afterAcknowledgingMutation({ documentVersion: 3 }) // patch mutation
690690
.toReturnChanged(unknownDoc('foo/bar', 3))
691691
.toContain(unknownDoc('foo/bar', 3))

packages/firestore/test/unit/model/mutation.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,9 @@ describe('Mutation', () => {
482482
);
483483
const transformResult = new MutationResult(version(7), []);
484484
const docV7Unknown = unknownDoc('collection/key', 7);
485-
const docV7Deleted = deletedDoc('collection/key', 7);
485+
const docV7Deleted = deletedDoc('collection/key', 7, {
486+
hasCommittedMutations: true
487+
});
486488
const docV7Committed = doc(
487489
'collection/key',
488490
7,

packages/firestore/test/util/helpers.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@ export function doc(
121121

122122
export function deletedDoc(
123123
keyStr: string,
124-
ver: TestSnapshotVersion
124+
ver: TestSnapshotVersion,
125+
options: DocumentOptions = {}
125126
): NoDocument {
126-
return new NoDocument(key(keyStr), version(ver));
127+
return new NoDocument(key(keyStr), version(ver), options);
127128
}
128129

129130
export function unknownDoc(

0 commit comments

Comments
 (0)