|
15 | 15 | #import <XCTest/XCTest.h> |
16 | 16 |
|
17 | 17 | #import "GoogleSignIn/Sources/GIDJSONSerializer/Fake/GIDFakeJSONSerializerImpl.h" |
| 18 | +#import "GoogleSignIn/Sources/GIDJSONSerializer/Implementation/GIDJSONSerializerImpl.h" |
18 | 19 | #import "GoogleSignIn/Sources/GIDTokenClaimsInternalOptions.h" |
19 | 20 | #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h" |
20 | 21 | #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDTokenClaim.h" |
|
23 | 24 | static NSString *const kNonEssentialAuthTimeExpectedJSON = @"{\"id_token\":{\"auth_time\":{\"essential\":false}}}"; |
24 | 25 |
|
25 | 26 | @interface GIDTokenClaimsInternalOptionsTest : XCTestCase |
| 27 | + |
26 | 28 | @property(nonatomic) GIDFakeJSONSerializerImpl *jsonSerializerFake; |
27 | 29 | @property(nonatomic) GIDTokenClaimsInternalOptions *tokenClaimsInternalOptions; |
| 30 | + |
28 | 31 | @end |
29 | 32 |
|
30 | 33 | @implementation GIDTokenClaimsInternalOptionsTest |
@@ -89,15 +92,22 @@ - (void)testValidatedJSONStringForClaims_WithConflictingClaims_ReturnsNilAndPopu |
89 | 92 |
|
90 | 93 | - (void)testValidatedJSONStringForClaims_WhenSerializationFails_ReturnsNilAndError { |
91 | 94 | NSSet *claims = [NSSet setWithObject:[GIDTokenClaim authTimeClaim]]; |
92 | | - NSError *expectedJSONError = [NSError errorWithDomain:@"com.fake.json" code:-999 userInfo:nil]; |
93 | | - _jsonSerializerFake.errorToReturn = expectedJSONError; |
| 95 | + NSError *expectedJSONError = [NSError errorWithDomain:kGIDSignInErrorDomain |
| 96 | + code:kGIDSignInErrorCodeJSONSerializationFailure |
| 97 | + userInfo:@{ |
| 98 | + NSLocalizedDescriptionKey: kGIDJSONSerializationErrorDescription, |
| 99 | + }]; |
| 100 | + _jsonSerializerFake.shouldFailJSONSerialization = YES; |
94 | 101 | NSError *actualError; |
95 | | - NSString *result = |
96 | | - [_tokenClaimsInternalOptions validatedJSONStringForClaims:claims error:&actualError]; |
| 102 | + NSString *result = [_tokenClaimsInternalOptions validatedJSONStringForClaims:claims |
| 103 | + error:&actualError]; |
97 | 104 |
|
98 | 105 | XCTAssertNil(result, @"The result should be nil when JSON serialization fails."); |
99 | | - XCTAssertEqualObjects(actualError, expectedJSONError, |
100 | | - @"The error from serialization should be passed back to the caller."); |
| 106 | + XCTAssertEqualObjects( |
| 107 | + actualError, |
| 108 | + expectedJSONError, |
| 109 | + @"The error from serialization should be passed back to the caller." |
| 110 | + ); |
101 | 111 | } |
102 | 112 |
|
103 | 113 | @end |
0 commit comments