aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm
diff options
context:
space:
mode:
authorGravatar Michael Lehenbauer <mikelehen@gmail.com>2018-04-23 10:03:55 -0700
committerGravatar GitHub <noreply@github.com>2018-04-23 10:03:55 -0700
commite4384c3e809556e75907df74cd116307f397472f (patch)
tree98841eba1d45eb94adcb798b6f792c16ba4b8d18 /Firestore/Example/Tests/Integration/API/FIRQueryTests.mm
parent8e70791465f9b5e4bb75dfc18de4a4ed90961974 (diff)
Array Contains Queries (not added to public headers yet). (#1138)
Diffstat (limited to 'Firestore/Example/Tests/Integration/API/FIRQueryTests.mm')
-rw-r--r--Firestore/Example/Tests/Integration/API/FIRQueryTests.mm45
1 files changed, 43 insertions, 2 deletions
diff --git a/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm b/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm
index d1c0d75..bdd3df1 100644
--- a/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm
+++ b/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm
@@ -20,8 +20,7 @@
#import "Firestore/Example/Tests/Util/FSTEventAccumulator.h"
#import "Firestore/Example/Tests/Util/FSTIntegrationTestCase.h"
-#import "Firestore/Source/API/FIRFirestore+Internal.h"
-#import "Firestore/Source/Core/FSTFirestoreClient.h"
+#import "Firestore/Source/API/FIRQuery+Internal.h"
@interface FIRQueryTests : FSTIntegrationTestCase
@end
@@ -294,4 +293,46 @@
]));
}
+// TODO(array-features): Enable once backend support lands.
+- (void)xtestArrayContainsQueries {
+ NSDictionary *testDocs = @{
+ @"a" : @{@"array" : @[ @42 ]},
+ @"b" : @{@"array" : @[ @"a", @42, @"c" ]},
+ @"c" : @{@"array" : @[ @41.999, @"42",
+ @{ @"a" : @[ @42 ] } ]},
+ @"d" : @{@"array" : @[ @42 ], @"array2" : @[ @"bingo" ]}
+ };
+ FIRCollectionReference *collection = [self collectionRefWithDocuments:testDocs];
+
+ // Search for 42
+ FIRQuerySnapshot *snapshot =
+ [self readDocumentSetForRef:[collection queryWhereField:@"array" arrayContains:@42]];
+ XCTAssertEqualObjects(FIRQuerySnapshotGetData(snapshot), (@[
+ @{ @"array" : @[ @42 ] },
+ @{ @"array" : @[ @"a", @42, @"c" ] },
+ @{ @"array" : @[ @42 ],
+ @"array2" : @[ @"bingo" ] }
+ ]));
+
+ // Search for "array" to contain both @42 and "a".
+ snapshot = [self readDocumentSetForRef:[[collection queryWhereField:@"array" arrayContains:@42]
+ queryWhereField:@"array"
+ arrayContains:@"a"]];
+ XCTAssertEqualObjects(FIRQuerySnapshotGetData(snapshot), (@[
+ @{ @"array" : @[ @"a", @42, @"c" ] },
+ ]));
+
+ // Search two different array fields ("array" contains 42 and "array2" contains "bingo").
+ snapshot = [self readDocumentSetForRef:[[collection queryWhereField:@"array" arrayContains:@42]
+ queryWhereField:@"array2"
+ arrayContains:@"bingo"]];
+ XCTAssertEqualObjects(FIRQuerySnapshotGetData(snapshot), (@[
+ @{ @"array" : @[ @42 ],
+ @"array2" : @[ @"bingo" ] }
+ ]));
+
+ // NOTE: The backend doesn't currently support null, NaN, objects, or arrays, so there isn't much
+ // of anything else interesting to test.
+}
+
@end