-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: publish Authenticator.user (#10)
* feat: publish Authenticator.user * test: add AuthException tests * style: fix text length
- Loading branch information
Showing
3 changed files
with
78 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
packages/flutterfire_authenticator/test/src/auth_exception_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import 'package:firebase_auth/firebase_auth.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:flutterfire_authenticator/authenticator.dart'; | ||
|
||
void main() { | ||
group('Constructor', () { | ||
test('AuthCancelled instance is created from the "cancel"', () { | ||
final e = FirebaseAuthException(code: 'cancel'); | ||
final sut = AuthException.fromError(e); | ||
expect(sut, isA<AuthCancelled>()); | ||
}); | ||
|
||
test('AuthCancelled instance is created from the "canceled"', () { | ||
final e = FirebaseAuthException(code: 'cancel'); | ||
final sut = AuthException.fromError(e); | ||
expect(sut, isA<AuthCancelled>()); | ||
}); | ||
|
||
test( | ||
'AuthCancelled instance is created from the "requires-recent-login"', | ||
() { | ||
final e = FirebaseAuthException(code: 'requires-recent-login'); | ||
final sut = AuthException.fromError(e); | ||
expect(sut, isA<AuthRequiresRecentSignIn>()); | ||
}, | ||
); | ||
|
||
test( | ||
'AuthCancelled instance is created from the "invalid-phone-number"', | ||
() { | ||
final e = FirebaseAuthException(code: 'invalid-phone-number'); | ||
final sut = AuthException.fromError(e); | ||
expect(sut, isA<AuthInvalidPhoneNumber>()); | ||
}, | ||
); | ||
|
||
test( | ||
'AuthCancelled instance is created from the "credential-already-in-use"', | ||
() { | ||
final e = FirebaseAuthException(code: 'credential-already-in-use'); | ||
final sut = AuthException.fromError(e); | ||
expect(sut, isA<AuthCredentialAlreadyInUse>()); | ||
}, | ||
); | ||
|
||
test( | ||
'AuthCancelled instance is created from the "network-request-failed"', | ||
() { | ||
final e = FirebaseAuthException(code: 'network-request-failed'); | ||
final sut = AuthException.fromError(e); | ||
expect(sut, isA<AuthFailedNetworkRequest>()); | ||
}, | ||
); | ||
}); | ||
} |