-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# *login screen text* ## ♻️ Current situation & Problem #131 ## ⚙️ Release Notes the exact text is not yet known, but PR is already preparing it in order to integrate the change as quickly and easily as possible. ## 📝 Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md): - [x] I agree to follow the [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md). --------- Signed-off-by: Basler182 <[email protected]> Co-authored-by: Eldi Cano <[email protected]>
- Loading branch information
Showing
5 changed files
with
91 additions
and
7 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,6 @@ | |
<string name="e_mail_address">E-Mail Address</string> | ||
<string name="signup">Signup</string> | ||
<string name="login">Login</string> | ||
<string name="login_screen_description">You may login to your existing account or create a new one if you don\'t have one already. You can also sign in with your Google Account. If you are having difficulty logging in or resetting your password, you can reach out to:\u00A0</string> | ||
<string name="engage_support_email">[email protected]</string> | ||
</resources> |
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package edu.stanford.spezi.module.account.login | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.net.Uri | ||
import com.google.common.truth.Truth.assertThat | ||
import edu.stanford.spezi.core.navigation.Navigator | ||
import edu.stanford.spezi.core.testing.CoroutineTestRule | ||
|
@@ -17,7 +20,12 @@ import io.mockk.coVerify | |
import io.mockk.every | ||
import io.mockk.just | ||
import io.mockk.mockk | ||
import io.mockk.mockkConstructor | ||
import io.mockk.mockkStatic | ||
import io.mockk.unmockkConstructor | ||
import io.mockk.unmockkStatic | ||
import io.mockk.verify | ||
import org.junit.After | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
@@ -30,6 +38,7 @@ class LoginViewModelTest { | |
private val accountEvents: AccountEvents = mockk(relaxed = true) | ||
private val validator: AuthValidator = mockk() | ||
private val navigator: Navigator = mockk() | ||
private val context: Context = mockk() | ||
|
||
@get:Rule | ||
val coroutineTestRule = CoroutineTestRule() | ||
|
@@ -43,15 +52,26 @@ class LoginViewModelTest { | |
} | ||
|
||
every { navigator.navigateTo(any()) } just Runs | ||
|
||
mockkStatic(Uri::class) | ||
mockkConstructor(Intent::class) | ||
|
||
loginViewModel = LoginViewModel( | ||
authenticationManager = authenticationManager, | ||
messageNotifier = messageNotifier, | ||
accountEvents = accountEvents, | ||
navigator = navigator, | ||
authValidator = validator | ||
authValidator = validator, | ||
context = context, | ||
) | ||
} | ||
|
||
@After | ||
fun tearDown() { | ||
unmockkStatic(Uri::class) | ||
unmockkConstructor(Intent::class) | ||
} | ||
|
||
@Test | ||
fun `it should update email correctly`() = | ||
runTestUnconfined { | ||
|
@@ -120,6 +140,28 @@ class LoginViewModelTest { | |
verify { navigator.navigateTo(expectedNavigationEvent) } | ||
} | ||
|
||
@Test | ||
fun `it should handle Email clicked correctly`() { | ||
// given | ||
val email = "[email protected]" | ||
val uri: Uri = mockk() | ||
every { Uri.parse("mailto:$email") } returns uri | ||
val intent = mockk<Intent>() | ||
every { anyConstructed<Intent>().setAction(Intent.ACTION_SENDTO) } returns intent | ||
every { intent.setData(uri) } returns intent | ||
every { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) } returns intent | ||
every { context.startActivity(intent) } just Runs | ||
|
||
// when | ||
loginViewModel.onAction(Action.EmailClicked(email)) | ||
|
||
// then | ||
verify { anyConstructed<Intent>().setAction(Intent.ACTION_SENDTO) } | ||
verify { intent.setData(uri) } | ||
verify { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) } | ||
verify { context.startActivity(intent) } | ||
} | ||
|
||
@Test | ||
fun `it should handle successful google sign in correctly`() = runTestUnconfined { | ||
// given | ||
|