@@ -174,18 +174,19 @@ - (SnapshotVersion)parseVersion:(NSNumber *_Nullable)version {
174
174
return testutil::Version (version.longLongValue );
175
175
}
176
176
177
- - (FSTDocumentViewChange *)parseChange : (NSArray *)change ofType : (FSTDocumentViewChangeType)type {
178
- BOOL hasMutations = NO ;
179
- for (NSUInteger i = 3 ; i < change.count ; ++i) {
180
- if ([change[i] isEqual: @" local" ]) {
181
- hasMutations = YES ;
182
- }
183
- }
184
- NSNumber *version = change[1 ];
185
- XCTAssert ([change[0 ] isKindOfClass: [NSString class ]]);
186
- FSTDocument *doc =
187
- FSTTestDoc (util::MakeString ((NSString *)change[0 ]), version.longLongValue , change[2 ],
188
- hasMutations ? FSTDocumentStateLocalMutations : FSTDocumentStateSynced);
177
+ - (FSTDocumentViewChange *)parseChange : (NSDictionary *)jsonDoc
178
+ ofType : (FSTDocumentViewChangeType)type {
179
+ NSNumber *version = jsonDoc[@" version" ];
180
+ NSDictionary *options = jsonDoc[@" options" ];
181
+ FSTDocumentState documentState = [options[@" hasLocalMutations" ] isEqualToNumber: @YES ]
182
+ ? FSTDocumentStateLocalMutations
183
+ : ([options[@" hasCommittedMutations" ] isEqualToNumber: @YES ]
184
+ ? FSTDocumentStateCommittedMutations
185
+ : FSTDocumentStateSynced);
186
+
187
+ XCTAssert ([jsonDoc[@" key" ] isKindOfClass: [NSString class ]]);
188
+ FSTDocument *doc = FSTTestDoc (util::MakeString ((NSString *)jsonDoc[@" key" ]),
189
+ version.longLongValue , jsonDoc[@" value" ], documentState);
189
190
return [FSTDocumentViewChange changeWithDocument: doc type: type];
190
191
}
191
192
@@ -270,11 +271,12 @@ - (void)doWatchEntity:(NSDictionary *)watchEntity {
270
271
[self doWatchEntity: watchSpec];
271
272
}
272
273
} else if (watchEntity[@" doc" ]) {
273
- NSArray *docSpec = watchEntity[@" doc" ];
274
- FSTDocumentKey *key = FSTTestDocKey (docSpec[0 ]);
275
- FSTObjectValue *_Nullable value =
276
- [docSpec[2 ] isKindOfClass: [NSNull class ]] ? nil : FSTTestObjectValue (docSpec[2 ]);
277
- SnapshotVersion version = [self parseVersion: docSpec[1 ]];
274
+ NSDictionary *docSpec = watchEntity[@" doc" ];
275
+ FSTDocumentKey *key = FSTTestDocKey (docSpec[@" key" ]);
276
+ FSTObjectValue *_Nullable value = [docSpec[@" value" ] isKindOfClass: [NSNull class ]]
277
+ ? nil
278
+ : FSTTestObjectValue (docSpec[@" value" ]);
279
+ SnapshotVersion version = [self parseVersion: docSpec[@" version" ]];
278
280
FSTMaybeDocument *doc = value ? [FSTDocument documentWithData: value
279
281
key: key
280
282
version:std: :move (version)
@@ -493,22 +495,22 @@ - (void)validateEvent:(FSTQueryEvent *)actual matches:(NSDictionary *)expected {
493
495
} else {
494
496
NSMutableArray *expectedChanges = [NSMutableArray array ];
495
497
NSMutableArray *removed = expected[@" removed" ];
496
- for (NSArray *changeSpec in removed) {
498
+ for (NSDictionary *changeSpec in removed) {
497
499
[expectedChanges
498
500
addObject: [self parseChange: changeSpec ofType: FSTDocumentViewChangeTypeRemoved]];
499
501
}
500
502
NSMutableArray *added = expected[@" added" ];
501
- for (NSArray *changeSpec in added) {
503
+ for (NSDictionary *changeSpec in added) {
502
504
[expectedChanges
503
505
addObject: [self parseChange: changeSpec ofType: FSTDocumentViewChangeTypeAdded]];
504
506
}
505
507
NSMutableArray *modified = expected[@" modified" ];
506
- for (NSArray *changeSpec in modified) {
508
+ for (NSDictionary *changeSpec in modified) {
507
509
[expectedChanges
508
510
addObject: [self parseChange: changeSpec ofType: FSTDocumentViewChangeTypeModified]];
509
511
}
510
512
NSMutableArray *metadata = expected[@" metadata" ];
511
- for (NSArray *changeSpec in metadata) {
513
+ for (NSDictionary *changeSpec in metadata) {
512
514
[expectedChanges
513
515
addObject: [self parseChange: changeSpec ofType: FSTDocumentViewChangeTypeMetadata]];
514
516
}
0 commit comments