@@ -898,7 +898,7 @@ - (void)testSdkOrdersQueryByDocumentIdTheSameWayOnlineAndOffline {
898898
899899- (void )testSnapshotListenerSortsUnicodeStringsInTheSameOrderAsServer {
900900 FIRCollectionReference *collRef = [self collectionRefWithDocuments: @{
901- @" a" : @{@" value" : @ " Łukasiewicz" },
901+ @" a" : @{@" value" : @" Łukasiewicz" },
902902 @" b" : @{@" value" : @" Sierpiński" },
903903 @" c" : @{@" value" : @" 岩澤" },
904904 @" d" : @{@" value" : @" 🄟" },
@@ -919,22 +919,117 @@ - (void)testSnapshotListenerSortsUnicodeStringsInTheSameOrderAsServer {
919919 XCTAssertEqualObjects (FIRQuerySnapshotGetIDs (watchSnapshot), expectedDocs);
920920
921921 [registration remove ];
922+
923+ [self checkOnlineAndOfflineQuery: query matchesResult: expectedDocs];
922924}
923925
924- - (void )testSnapshotListenerSortsUnicodeStringsTheSameWayOnlineAndOffline {
926+ - (void )testSnapshotListenerSortsUnicodeStringsInArrayInTheSameOrderAsServer {
925927 FIRCollectionReference *collRef = [self collectionRefWithDocuments: @{
926- @" a" : @{@" value" : @ " Łukasiewicz" },
927- @" b" : @{@" value" : @" Sierpiński" },
928- @" c" : @{@" value" : @" 岩澤" },
929- @" d" : @{@" value" : @" 🄟" },
930- @" e" : @{@" value" : @" P" },
931- @" f" : @{@" value" : @" ︒" },
932- @" g" : @{@" value" : @" 🐵" }
928+ @" a" : @{@" value" : @[ @ " Łukasiewicz" ] },
929+ @" b" : @{@" value" : @[ @ " Sierpiński" ] },
930+ @" c" : @{@" value" : @[ @ " 岩澤" ] },
931+ @" d" : @{@" value" : @[ @ " 🄟" ] },
932+ @" e" : @{@" value" : @[ @ " P" ] },
933+ @" f" : @{@" value" : @[ @ " ︒" ] },
934+ @" g" : @{@" value" : @[ @ " 🐵" ] }
933935
934936 }];
935937
936- [self checkOnlineAndOfflineQuery: [collRef queryOrderedByField: @" value" ]
937- matchesResult: @[ @" b" , @" a" , @" c" , @" f" , @" e" , @" d" , @" g" ]];
938+ FIRQuery *query = [collRef queryOrderedByField: @" value" ];
939+ NSArray <NSString *> *expectedDocs = @[ @" b" , @" a" , @" c" , @" f" , @" e" , @" d" , @" g" ];
940+ FIRQuerySnapshot *getSnapshot = [self readDocumentSetForRef: query];
941+ XCTAssertEqualObjects (FIRQuerySnapshotGetIDs (getSnapshot), expectedDocs);
942+
943+ id <FIRListenerRegistration> registration =
944+ [query addSnapshotListener: self .eventAccumulator.valueEventHandler];
945+ FIRQuerySnapshot *watchSnapshot = [self .eventAccumulator awaitEventWithName: @" Snapshot" ];
946+ XCTAssertEqualObjects (FIRQuerySnapshotGetIDs (watchSnapshot), expectedDocs);
947+
948+ [registration remove ];
949+
950+ [self checkOnlineAndOfflineQuery: query matchesResult: expectedDocs];
951+ }
952+
953+ - (void )testSnapshotListenerSortsUnicodeStringsInMapInTheSameOrderAsServer {
954+ FIRCollectionReference *collRef = [self collectionRefWithDocuments: @{
955+ @" a" : @{@" value" : @{@" foo" : @" Łukasiewicz" }},
956+ @" b" : @{@" value" : @{@" foo" : @" Sierpiński" }},
957+ @" c" : @{@" value" : @{@" foo" : @" 岩澤" }},
958+ @" d" : @{@" value" : @{@" foo" : @" 🄟" }},
959+ @" e" : @{@" value" : @{@" foo" : @" P" }},
960+ @" f" : @{@" value" : @{@" foo" : @" ︒" }},
961+ @" g" : @{@" value" : @{@" foo" : @" 🐵" }}
962+
963+ }];
964+
965+ FIRQuery *query = [collRef queryOrderedByField: @" value" ];
966+ NSArray <NSString *> *expectedDocs = @[ @" b" , @" a" , @" c" , @" f" , @" e" , @" d" , @" g" ];
967+ FIRQuerySnapshot *getSnapshot = [self readDocumentSetForRef: query];
968+ XCTAssertEqualObjects (FIRQuerySnapshotGetIDs (getSnapshot), expectedDocs);
969+
970+ id <FIRListenerRegistration> registration =
971+ [query addSnapshotListener: self .eventAccumulator.valueEventHandler];
972+ FIRQuerySnapshot *watchSnapshot = [self .eventAccumulator awaitEventWithName: @" Snapshot" ];
973+ XCTAssertEqualObjects (FIRQuerySnapshotGetIDs (watchSnapshot), expectedDocs);
974+
975+ [registration remove ];
976+
977+ [self checkOnlineAndOfflineQuery: query matchesResult: expectedDocs];
978+ }
979+
980+ - (void )testSnapshotListenerSortsUnicodeStringsInMapKeyInTheSameOrderAsServer {
981+ FIRCollectionReference *collRef = [self collectionRefWithDocuments: @{
982+ @" a" : @{@" value" : @{@" Łukasiewicz" : @" foo" }},
983+ @" b" : @{@" value" : @{@" Sierpiński" : @" foo" }},
984+ @" c" : @{@" value" : @{@" 岩澤" : @" foo" }},
985+ @" d" : @{@" value" : @{@" 🄟" : @" foo" }},
986+ @" e" : @{@" value" : @{@" P" : @" foo" }},
987+ @" f" : @{@" value" : @{@" ︒" : @" foo" }},
988+ @" g" : @{@" value" : @{@" 🐵" : @" foo" }}
989+
990+ }];
991+
992+ FIRQuery *query = [collRef queryOrderedByField: @" value" ];
993+ NSArray <NSString *> *expectedDocs = @[ @" b" , @" a" , @" c" , @" f" , @" e" , @" d" , @" g" ];
994+ FIRQuerySnapshot *getSnapshot = [self readDocumentSetForRef: query];
995+ XCTAssertEqualObjects (FIRQuerySnapshotGetIDs (getSnapshot), expectedDocs);
996+
997+ id <FIRListenerRegistration> registration =
998+ [query addSnapshotListener: self .eventAccumulator.valueEventHandler];
999+ FIRQuerySnapshot *watchSnapshot = [self .eventAccumulator awaitEventWithName: @" Snapshot" ];
1000+ XCTAssertEqualObjects (FIRQuerySnapshotGetIDs (watchSnapshot), expectedDocs);
1001+
1002+ [registration remove ];
1003+
1004+ [self checkOnlineAndOfflineQuery: query matchesResult: expectedDocs];
1005+ }
1006+
1007+ - (void )testSnapshotListenerSortsUnicodeStringsInDocumentKeyInTheSameOrderAsServer {
1008+ FIRCollectionReference *collRef = [self collectionRefWithDocuments: @{
1009+ @" Łukasiewicz" : @{@" value" : @" foo" },
1010+ @" Sierpiński" : @{@" value" : @" foo" },
1011+ @" 岩澤" : @{@" value" : @" foo" },
1012+ @" 🄟" : @{@" value" : @" foo" },
1013+ @" P" : @{@" value" : @" foo" },
1014+ @" ︒" : @{@" value" : @" foo" },
1015+ @" 🐵" : @{@" value" : @" foo" }
1016+
1017+ }];
1018+
1019+ FIRQuery *query = [collRef queryOrderedByFieldPath: [FIRFieldPath documentID ]];
1020+ NSArray <NSString *> *expectedDocs =
1021+ @[ @" Sierpiński" , @" Łukasiewicz" , @" 岩澤" , @" ︒" , @" P" , @" 🄟" , @" 🐵" ];
1022+ FIRQuerySnapshot *getSnapshot = [self readDocumentSetForRef: query];
1023+ XCTAssertEqualObjects (FIRQuerySnapshotGetIDs (getSnapshot), expectedDocs);
1024+
1025+ id <FIRListenerRegistration> registration =
1026+ [query addSnapshotListener: self .eventAccumulator.valueEventHandler];
1027+ FIRQuerySnapshot *watchSnapshot = [self .eventAccumulator awaitEventWithName: @" Snapshot" ];
1028+ XCTAssertEqualObjects (FIRQuerySnapshotGetIDs (watchSnapshot), expectedDocs);
1029+
1030+ [registration remove ];
1031+
1032+ [self checkOnlineAndOfflineQuery: query matchesResult: expectedDocs];
9381033}
9391034
9401035- (void )testCollectionGroupQueriesWithWhereFiltersOnArbitraryDocumentIDs {
0 commit comments