Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit d436a7c

Browse files
authored
[google_sign_in_platform_interface] Add availability to mock models (#5669)
1 parent 550ba3c commit d436a7c

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

packages/google_sign_in/google_sign_in_platform_interface/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 2.1.3
22

3+
* Enables mocking models by changing overridden operator == parameter type from `dynamic` to `Object`.
34
* Removes unnecessary imports.
45
* Adds `SignInInitParameters` class to hold all sign in params, including the new `forceCodeForRefreshToken`.
56

packages/google_sign_in/google_sign_in_platform_interface/lib/src/types.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class GoogleSignInUserData {
116116
@override
117117
// TODO(stuartmorgan): Make this class immutable in the next breaking change.
118118
// ignore: avoid_equals_and_hash_code_on_mutable_classes
119-
bool operator ==(dynamic other) {
119+
bool operator ==(Object other) {
120120
if (identical(this, other)) {
121121
return true;
122122
}
@@ -159,7 +159,7 @@ class GoogleSignInTokenData {
159159
@override
160160
// TODO(stuartmorgan): Make this class immutable in the next breaking change.
161161
// ignore: avoid_equals_and_hash_code_on_mutable_classes
162-
bool operator ==(dynamic other) {
162+
bool operator ==(Object other) {
163163
if (identical(this, other)) {
164164
return true;
165165
}

packages/google_sign_in/google_sign_in_platform_interface/test/google_sign_in_platform_interface_test.dart

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,44 @@ void main() {
2929
GoogleSignInPlatform.instance = ImplementsWithIsMock();
3030
});
3131
});
32+
33+
group('GoogleSignInTokenData', () {
34+
test('can be compared by == operator', () {
35+
final GoogleSignInTokenData firstInstance = GoogleSignInTokenData(
36+
accessToken: 'accessToken',
37+
idToken: 'idToken',
38+
serverAuthCode: 'serverAuthCode',
39+
);
40+
final GoogleSignInTokenData secondInstance = GoogleSignInTokenData(
41+
accessToken: 'accessToken',
42+
idToken: 'idToken',
43+
serverAuthCode: 'serverAuthCode',
44+
);
45+
expect(firstInstance == secondInstance, isTrue);
46+
});
47+
});
48+
49+
group('GoogleSignInUserData', () {
50+
test('can be compared by == operator', () {
51+
final GoogleSignInUserData firstInstance = GoogleSignInUserData(
52+
email: 'email',
53+
id: 'id',
54+
displayName: 'displayName',
55+
photoUrl: 'photoUrl',
56+
idToken: 'idToken',
57+
serverAuthCode: 'serverAuthCode',
58+
);
59+
final GoogleSignInUserData secondInstance = GoogleSignInUserData(
60+
email: 'email',
61+
id: 'id',
62+
displayName: 'displayName',
63+
photoUrl: 'photoUrl',
64+
idToken: 'idToken',
65+
serverAuthCode: 'serverAuthCode',
66+
);
67+
expect(firstInstance == secondInstance, isTrue);
68+
});
69+
});
3270
}
3371

3472
class ImplementsWithIsMock extends Mock implements GoogleSignInPlatform {

0 commit comments

Comments
 (0)