diff options
author | Sebastian Schmidt <mrschmidt@google.com> | 2018-06-12 10:58:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-12 10:58:35 -0700 |
commit | afea8d5aacf474b57b4364feda08be9ca195594b (patch) | |
tree | d43c39ae9f71e88d256012f4467cd2b707fc7ddd /Firestore/Example/Tests/Core/FSTViewTests.mm | |
parent | 0db8ef7dbe6c8c191252d33090dbb88b98735148 (diff) |
Refactor Remote Event (#1396)
Diffstat (limited to 'Firestore/Example/Tests/Core/FSTViewTests.mm')
-rw-r--r-- | Firestore/Example/Tests/Core/FSTViewTests.mm | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/Firestore/Example/Tests/Core/FSTViewTests.mm b/Firestore/Example/Tests/Core/FSTViewTests.mm index ec62d82..8c8d8a0 100644 --- a/Firestore/Example/Tests/Core/FSTViewTests.mm +++ b/Firestore/Example/Tests/Core/FSTViewTests.mm @@ -56,10 +56,8 @@ NS_ASSUME_NONNULL_BEGIN FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/2", 0, @{@"text" : @"msg2"}, NO); FSTDocument *doc3 = FSTTestDoc("rooms/other/messages/1", 0, @{@"text" : @"msg3"}, NO); - FSTViewSnapshot *_Nullable snapshot = - FSTTestApplyChanges(view, @[ doc1, doc2, doc3 ], - [FSTTargetChange changeWithDocuments:@[ doc1, doc2, doc3 ] - currentStatusUpdate:FSTCurrentStatusUpdateMarkCurrent]); + FSTViewSnapshot *_Nullable snapshot = FSTTestApplyChanges( + view, @[ doc1, doc2, doc3 ], FSTTestTargetChangeAckDocuments({doc1.key, doc2.key, doc3.key})); XCTAssertEqual(snapshot.query, query); @@ -90,8 +88,7 @@ NS_ASSUME_NONNULL_BEGIN // delete doc2, add doc3 FSTViewSnapshot *snapshot = FSTTestApplyChanges(view, @[ FSTTestDeletedDoc("rooms/eros/messages/2", 0), doc3 ], - [FSTTargetChange changeWithDocuments:@[ doc1, doc3 ] - currentStatusUpdate:FSTCurrentStatusUpdateMarkCurrent]); + FSTTestTargetChangeAckDocuments({doc1.key, doc3.key})); XCTAssertEqual(snapshot.query, query); @@ -216,10 +213,8 @@ NS_ASSUME_NONNULL_BEGIN FSTTestApplyChanges(view, @[ doc1, doc3 ], nil); // add doc2, which should push out doc3 - FSTViewSnapshot *snapshot = - FSTTestApplyChanges(view, @[ doc2 ], - [FSTTargetChange changeWithDocuments:@[ doc1, doc2, doc3 ] - currentStatusUpdate:FSTCurrentStatusUpdateMarkCurrent]); + FSTViewSnapshot *snapshot = FSTTestApplyChanges( + view, @[ doc2 ], FSTTestTargetChangeAckDocuments({doc1.key, doc2.key, doc3.key})); XCTAssertEqual(snapshot.query, query); @@ -263,9 +258,8 @@ NS_ASSUME_NONNULL_BEGIN previousChanges:viewDocChanges]; FSTViewSnapshot *snapshot = [view applyChangesToDocuments:viewDocChanges - targetChange:[FSTTargetChange - changeWithDocuments:@[ doc1, doc2, doc3, doc4 ] - currentStatusUpdate:FSTCurrentStatusUpdateMarkCurrent]] + targetChange:FSTTestTargetChangeAckDocuments( + {doc1.key, doc2.key, doc3.key, doc4.key})] .snapshot; XCTAssertEqual(snapshot.query, query); @@ -294,27 +288,21 @@ NS_ASSUME_NONNULL_BEGIN applyChangesToDocuments:[view computeChangesWithDocuments:FSTTestDocUpdates(@[ doc1 ])]]; XCTAssertEqualObjects(change.limboChanges, @[]); - change = - [view applyChangesToDocuments:[view computeChangesWithDocuments:FSTTestDocUpdates(@[])] - targetChange:[FSTTargetChange - changeWithDocuments:@[] - currentStatusUpdate:FSTCurrentStatusUpdateMarkCurrent]]; + change = [view applyChangesToDocuments:[view computeChangesWithDocuments:FSTTestDocUpdates(@[])] + targetChange:FSTTestTargetChangeMarkCurrent()]; XCTAssertEqualObjects( change.limboChanges, @[ [FSTLimboDocumentChange changeWithType:FSTLimboDocumentChangeTypeAdded key:doc1.key] ]); - change = [view - applyChangesToDocuments:[view computeChangesWithDocuments:FSTTestDocUpdates(@[])] - targetChange:[FSTTargetChange changeWithDocuments:@[ doc1 ] - currentStatusUpdate:FSTCurrentStatusUpdateNone]]; + change = [view applyChangesToDocuments:[view computeChangesWithDocuments:FSTTestDocUpdates(@[])] + targetChange:FSTTestTargetChangeAckDocuments({doc1.key})]; XCTAssertEqualObjects( change.limboChanges, @[ [FSTLimboDocumentChange changeWithType:FSTLimboDocumentChangeTypeRemoved key:doc1.key] ]); - change = [view - applyChangesToDocuments:[view computeChangesWithDocuments:FSTTestDocUpdates(@[ doc2 ])] - targetChange:[FSTTargetChange changeWithDocuments:@[ doc2 ] - currentStatusUpdate:FSTCurrentStatusUpdateNone]]; + change = + [view applyChangesToDocuments:[view computeChangesWithDocuments:FSTTestDocUpdates(@[ doc2 ])] + targetChange:FSTTestTargetChangeAckDocuments({doc2.key})]; XCTAssertEqualObjects(change.limboChanges, @[]); change = [view @@ -343,11 +331,9 @@ NS_ASSUME_NONNULL_BEGIN FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:DocumentKeySet{doc1.key, doc2.key}]; - FSTTargetChange *markCurrent = - [FSTTargetChange changeWithDocuments:@[] - currentStatusUpdate:FSTCurrentStatusUpdateMarkCurrent]; FSTViewDocumentChanges *changes = [view computeChangesWithDocuments:FSTTestDocUpdates(@[])]; - FSTViewChange *change = [view applyChangesToDocuments:changes targetChange:markCurrent]; + FSTViewChange *change = + [view applyChangesToDocuments:changes targetChange:FSTTestTargetChangeMarkCurrent()]; XCTAssertEqualObjects(change.limboChanges, @[]); } |