@@ -503,6 +503,39 @@ - (void)testRestorePreviousSignInWhenSignedOut {
503503 [_authState verify ];
504504}
505505
506+ - (void )testNotRestorePreviousSignInWhenSignedOutAndCompletionIsNil {
507+ [[[_authorization expect ] andReturn: _authState] authState ];
508+ [[[_authState expect ] andReturnValue: [NSNumber numberWithBool: NO ]] isAuthorized ];
509+
510+ [_signIn restorePreviousSignInWithCompletion: nil ];
511+
512+ XCTAssertNil (_signIn.currentUser );
513+ }
514+
515+ - (void )testRestorePreviousSignInWhenCompletionIsNil {
516+ [[[_authorization expect ] andReturn: _authState] authState ];
517+ [[[_authState expect ] andReturnValue: [NSNumber numberWithBool: YES ]] isAuthorized ];
518+
519+ OIDTokenResponse *tokenResponse =
520+ [OIDTokenResponse testInstanceWithIDToken: [OIDTokenResponse fatIDToken ]
521+ accessToken: kAccessToken
522+ expiresIn: nil
523+ refreshToken: kRefreshToken
524+ tokenRequest: nil ];
525+
526+ [[[_authState stub ] andReturn: tokenResponse] lastTokenResponse ];
527+
528+ // TODO: Create a real GIDGoogleUser to verify the signed in user value(#306).
529+ [[[_user stub ] andReturn: _user] alloc ];
530+ (void )[[[_user expect ] andReturn: _user] initWithAuthState: OCMOCK_ANY
531+ profileData: OCMOCK_ANY];
532+ XCTAssertNil (_signIn.currentUser );
533+
534+ [_signIn restorePreviousSignInWithCompletion: nil ];
535+
536+ XCTAssertNotNil (_signIn.currentUser );
537+ }
538+
506539- (void )testOAuthLogin {
507540 [self OAuthLoginWithAddScopesFlow: NO
508541 authError: nil
@@ -1239,7 +1272,7 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow
12391272 [[[_authState expect ] andReturn: tokenResponse] lastTokenResponse ];
12401273 if (oldAccessToken) {
12411274#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
1242- // Corresponds to EMM support
1275+ // Corresponds to EMM support
12431276 [[[_authState expect ] andReturn: authResponse] lastAuthorizationResponse ];
12441277#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
12451278 [[[_authState expect ] andReturn: tokenResponse] lastTokenResponse ];
0 commit comments