aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Example/Tests/Integration/API/FIRDatabaseTests.m
diff options
context:
space:
mode:
authorGravatar Michael Lehenbauer <mikelehen@gmail.com>2017-10-19 08:23:25 -0700
committerGravatar GitHub <noreply@github.com>2017-10-19 08:23:25 -0700
commit024788e38a5e506cf4861aa66afda2bc3b9115e1 (patch)
tree43af440462ae283c1277de040c689a724d047098 /Firestore/Example/Tests/Integration/API/FIRDatabaseTests.m
parentb561342aa69f30fbd5e66927501def426ba8337e (diff)
Add isEqual() and port DocumentReference array test. (#380)
* Ports the test for the fix I made for Android for DocumentReference objects in arrays (bug not present in iOS). * Implements isEqual on FIRQuery and FIRDocumentReference.
Diffstat (limited to 'Firestore/Example/Tests/Integration/API/FIRDatabaseTests.m')
-rw-r--r--Firestore/Example/Tests/Integration/API/FIRDatabaseTests.m34
1 files changed, 34 insertions, 0 deletions
diff --git a/Firestore/Example/Tests/Integration/API/FIRDatabaseTests.m b/Firestore/Example/Tests/Integration/API/FIRDatabaseTests.m
index d22552a..47ba95b 100644
--- a/Firestore/Example/Tests/Integration/API/FIRDatabaseTests.m
+++ b/Firestore/Example/Tests/Integration/API/FIRDatabaseTests.m
@@ -680,6 +680,40 @@
XCTAssertEqual(q.firestore, self.db);
}
+- (void)testDocumentReferenceEquality {
+ FIRFirestore *firestore = self.db;
+ FIRDocumentReference *docRef = [firestore documentWithPath:@"foo/bar"];
+ XCTAssertEqualObjects([firestore documentWithPath:@"foo/bar"], docRef);
+ XCTAssertEqualObjects([docRef collectionWithPath:@"blah"].parent, docRef);
+
+ XCTAssertNotEqualObjects([firestore documentWithPath:@"foo/BAR"], docRef);
+
+ FIRFirestore *otherFirestore = [self firestore];
+ XCTAssertNotEqualObjects([otherFirestore documentWithPath:@"foo/bar"], docRef);
+}
+
+- (void)testQueryReferenceEquality {
+ FIRFirestore *firestore = self.db;
+ FIRQuery *query =
+ [[[firestore collectionWithPath:@"foo"] queryOrderedByField:@"bar"] queryWhereField:@"baz"
+ isEqualTo:@42];
+ FIRQuery *query2 =
+ [[[firestore collectionWithPath:@"foo"] queryOrderedByField:@"bar"] queryWhereField:@"baz"
+ isEqualTo:@42];
+ XCTAssertEqualObjects(query, query2);
+
+ FIRQuery *query3 =
+ [[[firestore collectionWithPath:@"foo"] queryOrderedByField:@"BAR"] queryWhereField:@"baz"
+ isEqualTo:@42];
+ XCTAssertNotEqualObjects(query, query3);
+
+ FIRFirestore *otherFirestore = [self firestore];
+ FIRQuery *query4 = [[[otherFirestore collectionWithPath:@"foo"] queryOrderedByField:@"bar"]
+ queryWhereField:@"baz"
+ isEqualTo:@42];
+ XCTAssertNotEqualObjects(query, query4);
+}
+
- (void)testCanTraverseCollectionsAndDocuments {
NSString *expected = @"a/b/c/d";
// doc path from root Firestore.