Skip to content

Commit c36dec9

Browse files
Minor test refactor
1 parent b0d9e0c commit c36dec9

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

packages/google_sign_in/google_sign_in_ios/test/google_sign_in_ios_test.dart

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,36 +1014,38 @@ void main() {
10141014
},
10151015
);
10161016

1017-
test('does not return cached token from authn when user changes', () async {
1017+
test('does not return cached token from authn if user changes', () async {
10181018
const List<String> scopes = <String>['a', 'b'];
10191019
const String accessToken = 'accessToken';
10201020
const String serverAuthCode = 'authCode';
1021+
final UserData previousUser = UserData(
1022+
displayName: 'Previous user',
1023+
1024+
userId: 'different_id',
1025+
photoUrl: _testUser.photoUrl,
1026+
idToken: '',
1027+
);
1028+
final UserData newUser = UserData(
1029+
displayName: _testUser.displayName,
1030+
email: _testUser.email,
1031+
userId: _testUser.id,
1032+
photoUrl: _testUser.photoUrl,
1033+
idToken: '',
1034+
);
10211035
when(mockApi.signIn(scopes, null)).thenAnswer(
10221036
(_) async => SignInResult(
10231037
success: SignInSuccess(
1024-
user: UserData(
1025-
displayName: 'Previous user',
1026-
1027-
userId: 'different_id',
1028-
photoUrl: _testUser.photoUrl,
1029-
idToken: '',
1030-
),
1038+
user: previousUser,
10311039
accessToken: accessToken,
10321040
serverAuthCode: serverAuthCode,
10331041
grantedScopes: <String>[],
10341042
),
10351043
),
10361044
);
1037-
when(mockApi.getRefreshedAuthorizationTokens(_testUser.id)).thenAnswer(
1045+
when(mockApi.getRefreshedAuthorizationTokens(newUser.userId)).thenAnswer(
10381046
(_) async => SignInResult(
10391047
success: SignInSuccess(
1040-
user: UserData(
1041-
displayName: _testUser.displayName,
1042-
email: _testUser.email,
1043-
userId: _testUser.id,
1044-
photoUrl: _testUser.photoUrl,
1045-
idToken: '',
1046-
),
1048+
user: newUser,
10471049
accessToken: accessToken,
10481050
// serverAuthCode will always be null for getRefreshedAuthorizationTokens.
10491051
grantedScopes: scopes,
@@ -1059,8 +1061,8 @@ void main() {
10591061
ServerAuthorizationTokensForScopesParameters(
10601062
request: AuthorizationRequestDetails(
10611063
scopes: scopes,
1062-
userId: _testUser.id,
1063-
email: _testUser.email,
1064+
userId: newUser.userId,
1065+
email: newUser.email,
10641066
promptIfUnauthorized: false,
10651067
),
10661068
),

0 commit comments

Comments
 (0)