Skip to content

Commit

Permalink
... but still clear current user on sign out
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelowolf committed Sep 4, 2024
1 parent 78aea40 commit 767582c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/src/firebase_auth_mocks_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class MockFirebaseAuth implements FirebaseAuth {
Future<void> signOut() async {
maybeThrowException(this, Invocation.method(#signOut, [null]));

_currentUser = null;
_notifyCredential(null);
}

Expand Down
11 changes: 11 additions & 0 deletions test/firebase_auth_mocks_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,17 @@ void main() {
});

group('Sign out', () {
test('Returns null after sign out', () async {
final auth = MockFirebaseAuth(signedIn: true, mockUser: tUser);
final user = auth.currentUser;

await auth.signOut();

expect(auth.currentUser, isNull);
expect(auth.authStateChanges(), emitsInOrder([user, null]));
expect(auth.userChanges(), emitsInOrder([user, null]));
});

test('Can sign in again after sign out', () async {
final auth = MockFirebaseAuth(signedIn: true, mockUser: tUser);
final user = auth.currentUser;
Expand Down

0 comments on commit 767582c

Please sign in to comment.