aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm
diff options
context:
space:
mode:
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 {