-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow setting mock user to null
#112
Changes from all commits
17ceea3
a2fc706
78aea40
767582c
030131c
c4b8eec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,15 +239,46 @@ void main() { | |
expect(idTokenResult.claims, {'weight': 70}); | ||
}); | ||
|
||
test('Returns null after sign out', () async { | ||
final auth = MockFirebaseAuth(signedIn: true, mockUser: tUser); | ||
final user = auth.currentUser; | ||
group('Sign out', () { | ||
test('Returns null after sign out', () async { | ||
final auth = MockFirebaseAuth(signedIn: true, mockUser: tUser); | ||
final user = auth.currentUser; | ||
|
||
await auth.signOut(); | ||
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; | ||
|
||
await auth.signOut(); | ||
|
||
expect(auth.currentUser, isNull); | ||
expect(auth.authStateChanges(), emitsInOrder([user, null])); | ||
expect(auth.userChanges(), emitsInOrder([user, null])); | ||
auth.mockUser = tUser; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since signing out does not set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes, you're right - this should have been removed too. I'll clean that up There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, looks like you fixed it - I missed your other comment. Thanks! |
||
await auth.signInWithProvider(AppleAuthProvider()); | ||
|
||
expect(auth.authStateChanges(), | ||
emitsInOrder([user, null, auth.currentUser])); | ||
expect(auth.userChanges(), emitsInOrder([user, null, auth.currentUser])); | ||
}); | ||
|
||
test('Can sign in anonymously after sign out', () async { | ||
final auth = MockFirebaseAuth(signedIn: true, mockUser: tUser); | ||
final user = auth.currentUser; | ||
|
||
await auth.signOut(); | ||
|
||
auth.mockUser = null; | ||
await auth.signInAnonymously(); | ||
|
||
expect(auth.currentUser!.isAnonymous, isTrue); | ||
expect(auth.authStateChanges(), | ||
emitsInOrder([user, null, auth.currentUser])); | ||
expect(auth.userChanges(), emitsInOrder([user, null, auth.currentUser])); | ||
}); | ||
}); | ||
|
||
test('sendPasswordResetEmail works', () async { | ||
|
@@ -774,7 +805,7 @@ void main() { | |
expect(decodedToken['bodyHeight'], 169); | ||
}); | ||
|
||
test('The customClain should exist after sign-out and sign-in', () async { | ||
test('The customClaim should exist after sign-out and sign-in', () async { | ||
final auth = MockFirebaseAuth( | ||
mockUser: MockUser(customClaim: {'role': 'admin', 'bodyHeight': 169}), | ||
signedIn: true, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!