@@ -956,9 +956,7 @@ class SelectionSet_EqualityTests: XCTestCase {
956956
957957 // MARK: - Integration Tests
958958
959- func test__equatable__givenQueryResponseFetchedFromStore( )
960- async throws
961- {
959+ func test__equatable__givenQueryResponseFetchedFromStore( ) async throws {
962960 // given
963961 class GivenSelectionSet : MockSelectionSet {
964962 override class var __selections : [ Selection ] {
@@ -1024,4 +1022,113 @@ class SelectionSet_EqualityTests: XCTestCase {
10241022 await fulfillment ( of: [ updateCompletedExpectation] , timeout: 1.0 )
10251023 }
10261024
1025+ func test__equatable__givenFailingModelFromCI_sameValue_shouldBeEqual( ) throws {
1026+ // given
1027+ class ReverseFriendsQuery : MockSelectionSet {
1028+ override class var __selections : [ Selection ] { [
1029+ . field( " hero " , Hero ? . self, arguments: [ " id " : . variable( " id " ) ] )
1030+ ] }
1031+
1032+ var hero : Hero { __data [ " hero " ] }
1033+
1034+ class Hero : MockSelectionSet {
1035+ override class var __selections : [ Selection ] { [
1036+ . field( " __typename " , String . self) ,
1037+ . field( " id " , String . self) ,
1038+ . field( " name " , String . self) ,
1039+ . field( " friendsConnection " , FriendsConnection . self, arguments: [
1040+ " first " : . variable( " first " ) ,
1041+ " before " : . variable( " before " ) ,
1042+ ] ) ,
1043+ ] }
1044+
1045+ var name : String { __data [ " name " ] }
1046+ var id : String { __data [ " id " ] }
1047+ var friendsConnection : FriendsConnection { __data [ " friendsConnection " ] }
1048+
1049+ class FriendsConnection : MockSelectionSet {
1050+ override class var __selections : [ Selection ] { [
1051+ . field( " __typename " , String . self) ,
1052+ . field( " totalCount " , Int . self) ,
1053+ . field( " friends " , [ Character ] . self) ,
1054+ . field( " pageInfo " , PageInfo . self) ,
1055+ ] }
1056+
1057+ var totalCount : Int { __data [ " totalCount " ] }
1058+ var friends : [ Character ] { __data [ " friends " ] }
1059+ var pageInfo : PageInfo { __data [ " pageInfo " ] }
1060+
1061+ class Character : MockSelectionSet {
1062+ override class var __selections : [ Selection ] { [
1063+ . field( " __typename " , String . self) ,
1064+ . field( " name " , String . self) ,
1065+ . field( " id " , String . self) ,
1066+ ] }
1067+
1068+ var name : String { __data [ " name " ] }
1069+ var id : String { __data [ " id " ] }
1070+ }
1071+
1072+ class PageInfo : MockSelectionSet {
1073+ override class var __selections : [ Selection ] { [
1074+ . field( " __typename " , String . self) ,
1075+ . field( " startCursor " , Optional< String> . self ) ,
1076+ . field( " hasPreviousPage " , Bool . self) ,
1077+ ] }
1078+
1079+ var startCursor : String ? { __data [ " startCursor " ] }
1080+ var hasPreviousPage : Bool { __data [ " hasPreviousPage " ] }
1081+ }
1082+ }
1083+ }
1084+ }
1085+
1086+ // when
1087+ let query = MockQuery < ReverseFriendsQuery > ( )
1088+ query. __variables = [ " id " : " 2001 " , " first " : 2 , " before " : " Y3Vyc29yMw== " ]
1089+
1090+ let body : JSONObject = [ " data " : [
1091+ " hero " : [
1092+ " __typename " : " Droid " ,
1093+ " id " : " 2001 " ,
1094+ " name " : " R2-D2 " ,
1095+ " friendsConnection " : [
1096+ " __typename " : " FriendsConnection " ,
1097+ " totalCount " : 3 ,
1098+ " friends " : [
1099+ [
1100+ " __typename " : " Human " ,
1101+ " name " : " Han Solo " ,
1102+ " id " : " 1002 " ,
1103+ ] ,
1104+ [
1105+ " __typename " : " Human " ,
1106+ " name " : " Leia Organa " ,
1107+ " id " : " 1003 " ,
1108+ ]
1109+ ] ,
1110+ " pageInfo " : [
1111+ " __typename " : " PageInfo " ,
1112+ " startCursor " : " Y3Vyc29yMg== " ,
1113+ " hasPreviousPage " : true
1114+ ]
1115+ ]
1116+ ]
1117+ ] ]
1118+
1119+ let first = try GraphQLResponse (
1120+ operation: query,
1121+ body: body
1122+ ) . parseResult ( ) . 0 . data
1123+
1124+ let second = try GraphQLResponse (
1125+ operation: query,
1126+ body: body
1127+ ) . parseResult ( ) . 0 . data
1128+
1129+ // then
1130+ XCTAssertEqual ( first, second)
1131+ expect ( first) . to ( equal ( second) )
1132+ }
1133+
10271134}
0 commit comments