@@ -158,50 +158,59 @@ - (void)testError {
158158 XCTAssertEqualObjects (map, self.errorMap );
159159}
160160
161+ - (void )testErrorWithNSNumberAsUserInfo {
162+ NSError *error = [NSError errorWithDomain: SKErrorDomain
163+ code: 3
164+ userInfo: @{ @" key" : @42 }];
165+ NSDictionary *expectedMap = @{
166+ @" domain" : SKErrorDomain,
167+ @" code" : @3 ,
168+ @" userInfo" : @{ @" key" : @42 }
169+ };
170+ NSDictionary *map = [FIAObjectTranslator getMapFromNSError: error];
171+ XCTAssertEqualObjects (expectedMap, map);
172+ }
173+
161174- (void )testErrorWithMultipleUnderlyingErrors {
162- if (@available (iOS 10.0 , *)) {
163- NSError *underlyingErrorOne = [NSError errorWithDomain: SKErrorDomain code: 2 userInfo: nil ];
164- NSError *underlyingErrorTwo = [NSError errorWithDomain: SKErrorDomain code: 1 userInfo: nil ];
165- NSError *mainError = [NSError
166- errorWithDomain: SKErrorDomain
167- code: 3
168- userInfo: @{@" underlyingErrors" : @[ underlyingErrorOne, underlyingErrorTwo ]}];
169- NSDictionary *expectedMap = @{
170- @" domain" : SKErrorDomain,
171- @" code" : @3 ,
172- @" userInfo" : @{
173- @" underlyingErrors" : @[
174- @{@" domain" : SKErrorDomain, @" code" : @2 , @" userInfo" : @{}},
175- @{@" domain" : SKErrorDomain, @" code" : @1 , @" userInfo" : @{}}
176- ]
177- }
178- };
179- NSDictionary *map = [FIAObjectTranslator getMapFromNSError: mainError];
180- XCTAssertEqualObjects (expectedMap, map);
181- }
175+ NSError *underlyingErrorOne = [NSError errorWithDomain: SKErrorDomain code: 2 userInfo: nil ];
176+ NSError *underlyingErrorTwo = [NSError errorWithDomain: SKErrorDomain code: 1 userInfo: nil ];
177+ NSError *mainError = [NSError
178+ errorWithDomain: SKErrorDomain
179+ code: 3
180+ userInfo: @{@" underlyingErrors" : @[ underlyingErrorOne, underlyingErrorTwo ]}];
181+ NSDictionary *expectedMap = @{
182+ @" domain" : SKErrorDomain,
183+ @" code" : @3 ,
184+ @" userInfo" : @{
185+ @" underlyingErrors" : @[
186+ @{@" domain" : SKErrorDomain, @" code" : @2 , @" userInfo" : @{}},
187+ @{@" domain" : SKErrorDomain, @" code" : @1 , @" userInfo" : @{}}
188+ ]
189+ }
190+ };
191+ NSDictionary *map = [FIAObjectTranslator getMapFromNSError: mainError];
192+ XCTAssertEqualObjects (expectedMap, map);
182193}
183194
184195- (void )testErrorWithUnsupportedUserInfo {
185- if (@available (iOS 10.0 , *)) {
186- NSError *error = [NSError errorWithDomain: SKErrorDomain
187- code: 3
188- userInfo: @{@" user_info" : [[NSObject alloc ] init ]}];
189- NSDictionary *expectedMap = @{
190- @" domain" : SKErrorDomain,
191- @" code" : @3 ,
192- @" userInfo" : @{
193- @" user_info" : [NSString
194- stringWithFormat:
195- @" Unable to encode native userInfo object of type %@ to map. Please submit an "
196- @" issue at https://github.com/flutter/flutter/issues/new with the title "
197- @" \" [in_app_purchase_storekit] Unable to encode userInfo of type %@ \" and add "
198- @" reproduction steps and the error details in the description field." ,
199- [NSObject class ], [NSObject class ]]
200- }
201- };
202- NSDictionary *map = [FIAObjectTranslator getMapFromNSError: error];
203- XCTAssertEqualObjects (expectedMap, map);
204- }
196+ NSError *error = [NSError errorWithDomain: SKErrorDomain
197+ code: 3
198+ userInfo: @{@" user_info" : [[NSObject alloc ] init ]}];
199+ NSDictionary *expectedMap = @{
200+ @" domain" : SKErrorDomain,
201+ @" code" : @3 ,
202+ @" userInfo" : @{
203+ @" user_info" : [NSString
204+ stringWithFormat:
205+ @" Unable to encode native userInfo object of type %@ to map. Please submit an "
206+ @" issue at https://github.com/flutter/flutter/issues/new with the title "
207+ @" \" [in_app_purchase_storekit] Unable to encode userInfo of type %@ \" and add "
208+ @" reproduction steps and the error details in the description field." ,
209+ [NSObject class ], [NSObject class ]]
210+ }
211+ };
212+ NSDictionary *map = [FIAObjectTranslator getMapFromNSError: error];
213+ XCTAssertEqualObjects (expectedMap, map);
205214}
206215
207216- (void )testLocaleToMap {
0 commit comments