Line data Source code
1 : import 'package:redfire/types.dart';
2 : import 'package:sign_in_with_apple/sign_in_with_apple.dart';
3 :
4 : class SignInWithAppleWrapperExample {
5 0 : static SignInWithAppleWrapper get cancellingMock =>
6 0 : _FakeSignInWithAppleWrapperCancels();
7 :
8 0 : static SignInWithAppleWrapper get throwingFake =>
9 0 : _FakeSignInWithAppleWrapperThrows();
10 : }
11 :
12 : // When the user cancels during the signin process, it seems a particular
13 : // exception is thrown - TODO: review docs and run tests to see if this is true
14 : class _FakeSignInWithAppleWrapperCancels implements SignInWithAppleWrapper {
15 0 : @override
16 : Future<AuthorizationCredentialAppleID> getCredential(
17 : {List<AppleIDAuthorizationScopes>? scopes}) {
18 : throw const SignInWithAppleAuthorizationException(
19 : code: AuthorizationErrorCode.canceled,
20 : message: 'User canceled authorization',
21 : );
22 : }
23 : }
24 :
25 : class _FakeSignInWithAppleWrapperThrows implements SignInWithAppleWrapper {
26 0 : @override
27 : Future<AuthorizationCredentialAppleID> getCredential(
28 : {List<AppleIDAuthorizationScopes>? scopes}) {
29 0 : throw Exception('AppleSignIn.signIn');
30 : }
31 : }
|