From 644fda282a2e0916c4cc3cd9d8a7b4e316cddc49 Mon Sep 17 00:00:00 2001 From: Hwan-seok Date: Tue, 10 May 2022 02:56:49 +0900 Subject: [PATCH] Fix: Add availability to mock some models --- .../CHANGELOG.md | 3 +- .../lib/src/types.dart | 4 +- .../pubspec.yaml | 2 +- ...oogle_sign_in_platform_interface_test.dart | 38 +++++++++++++++++++ 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/packages/google_sign_in/google_sign_in_platform_interface/CHANGELOG.md b/packages/google_sign_in/google_sign_in_platform_interface/CHANGELOG.md index da214d3ce6a9..ad498dd8642a 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in_platform_interface/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 2.1.3 +* Enables mocking models by changing overridden operator == parameter type from `dynamic` to `Object`. * Removes unnecessary imports. ## 2.1.2 diff --git a/packages/google_sign_in/google_sign_in_platform_interface/lib/src/types.dart b/packages/google_sign_in/google_sign_in_platform_interface/lib/src/types.dart index bc50a1d2516d..bd74419d19a4 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/lib/src/types.dart +++ b/packages/google_sign_in/google_sign_in_platform_interface/lib/src/types.dart @@ -79,7 +79,7 @@ class GoogleSignInUserData { @override // TODO(stuartmorgan): Make this class immutable in the next breaking change. // ignore: avoid_equals_and_hash_code_on_mutable_classes - bool operator ==(dynamic other) { + bool operator ==(Object other) { if (identical(this, other)) { return true; } @@ -122,7 +122,7 @@ class GoogleSignInTokenData { @override // TODO(stuartmorgan): Make this class immutable in the next breaking change. // ignore: avoid_equals_and_hash_code_on_mutable_classes - bool operator ==(dynamic other) { + bool operator ==(Object other) { if (identical(this, other)) { return true; } diff --git a/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml b/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml index a5bbaedd51e7..0deafe80a863 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml @@ -4,7 +4,7 @@ repository: https://github.com/flutter/plugins/tree/main/packages/google_sign_in issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22 # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 2.1.2 +version: 2.1.3 environment: sdk: ">=2.12.0 <3.0.0" diff --git a/packages/google_sign_in/google_sign_in_platform_interface/test/google_sign_in_platform_interface_test.dart b/packages/google_sign_in/google_sign_in_platform_interface/test/google_sign_in_platform_interface_test.dart index 78e57a3eb2ac..bf960abc7375 100644 --- a/packages/google_sign_in/google_sign_in_platform_interface/test/google_sign_in_platform_interface_test.dart +++ b/packages/google_sign_in/google_sign_in_platform_interface/test/google_sign_in_platform_interface_test.dart @@ -29,6 +29,44 @@ void main() { GoogleSignInPlatform.instance = ImplementsWithIsMock(); }); }); + + group('GoogleSignInTokenData', () { + test('can be compared by == operator', () { + final GoogleSignInTokenData firstInstance = GoogleSignInTokenData( + accessToken: 'accessToken', + idToken: 'idToken', + serverAuthCode: 'serverAuthCode', + ); + final GoogleSignInTokenData secondInstance = GoogleSignInTokenData( + accessToken: 'accessToken', + idToken: 'idToken', + serverAuthCode: 'serverAuthCode', + ); + expect(firstInstance == secondInstance, isTrue); + }); + }); + + group('GoogleSignInUserData', () { + test('can be compared by == operator', () { + final GoogleSignInUserData firstInstance = GoogleSignInUserData( + email: 'email', + id: 'id', + displayName: 'displayName', + photoUrl: 'photoUrl', + idToken: 'idToken', + serverAuthCode: 'serverAuthCode', + ); + final GoogleSignInUserData secondInstance = GoogleSignInUserData( + email: 'email', + id: 'id', + displayName: 'displayName', + photoUrl: 'photoUrl', + idToken: 'idToken', + serverAuthCode: 'serverAuthCode', + ); + expect(firstInstance == secondInstance, isTrue); + }); + }); } class ImplementsWithIsMock extends Mock implements GoogleSignInPlatform {