aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm
diff options
context:
space:
mode:
authorGravatar Michael Lehenbauer <mikelehen@gmail.com>2018-04-17 15:55:29 -0700
committerGravatar GitHub <noreply@github.com>2018-04-17 15:55:29 -0700
commite36cc9610b11dfd2581ba5e3fda1917e0d5e697a (patch)
tree1a2861ce32463a225f1960c20e2f25b195d39183 /Firestore/Example/Tests/Integration/API/FIRValidationTests.mm
parent2f86a297446b7b2e4832bc2868fe63d54211144f (diff)
Integration tests, changelog, and minor fixes for array transforms. (#1108)
Diffstat (limited to 'Firestore/Example/Tests/Integration/API/FIRValidationTests.mm')
-rw-r--r--Firestore/Example/Tests/Integration/API/FIRValidationTests.mm45
1 files changed, 45 insertions, 0 deletions
diff --git a/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm b/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm
index 2c6a2a8..2361fd0 100644
--- a/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm
+++ b/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm
@@ -363,6 +363,51 @@
}
}
+#pragma mark - ArrayUnion / ArrayRemove Validation
+
+- (void)testArrayTransformsInQueriesFail {
+ FSTAssertThrows(
+ [[self collectionRef] queryWhereField:@"test"
+ isEqualTo:@{
+ @"test" : [FIRFieldValue fieldValueForArrayUnion:@[ @1 ]]
+ }],
+ @"FieldValue.arrayUnion() can only be used with updateData() and setData() (found in field "
+ "test)");
+
+ FSTAssertThrows(
+ [[self collectionRef] queryWhereField:@"test"
+ isEqualTo:@{
+ @"test" : [FIRFieldValue fieldValueForArrayRemove:@[ @1 ]]
+ }],
+ @"FieldValue.arrayRemove() can only be used with updateData() and setData() (found in field "
+ @"test)");
+}
+
+- (void)testInvalidArrayTransformElementFails {
+ [self expectWrite:@{
+ @"foo" : [FIRFieldValue fieldValueForArrayUnion:@[ @1, self ]]
+ }
+ toFailWithReason:@"Unsupported type: FIRValidationTests"];
+
+ [self expectWrite:@{
+ @"foo" : [FIRFieldValue fieldValueForArrayRemove:@[ @1, self ]]
+ }
+ toFailWithReason:@"Unsupported type: FIRValidationTests"];
+}
+
+- (void)testArraysInArrayTransformsFail {
+ // This would result in a directly nested array which is not supported.
+ [self expectWrite:@{
+ @"foo" : [FIRFieldValue fieldValueForArrayUnion:@[ @1, @[ @"nested" ] ]]
+ }
+ toFailWithReason:@"Nested arrays are not supported"];
+
+ [self expectWrite:@{
+ @"foo" : [FIRFieldValue fieldValueForArrayRemove:@[ @1, @[ @"nested" ] ]]
+ }
+ toFailWithReason:@"Nested arrays are not supported"];
+}
+
#pragma mark - Query Validation
- (void)testQueryWithNonPositiveLimitFails {