mirror of
https://github.com/bitwarden/android.git
synced 2024-12-18 07:11:51 +03:00
BIT-589 Prevent crash on Landing when navigating with empty input (#59)
This commit is contained in:
parent
3de916cc20
commit
35483408b2
2 changed files with 14 additions and 1 deletions
|
@ -49,6 +49,10 @@ class LandingViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleContinueButtonClicked() {
|
private fun handleContinueButtonClicked() {
|
||||||
|
// TODO: add actual validation here: BIT-193
|
||||||
|
if (mutableStateFlow.value.emailInput.isBlank()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
sendEvent(LandingEvent.NavigateToLogin(mutableStateFlow.value.emailInput))
|
sendEvent(LandingEvent.NavigateToLogin(mutableStateFlow.value.emailInput))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,15 +34,24 @@ class LandingViewModelTest : BaseViewModelTest() {
|
||||||
@Test
|
@Test
|
||||||
fun `ContinueButtonClick should emit NavigateToLogin`() = runTest {
|
fun `ContinueButtonClick should emit NavigateToLogin`() = runTest {
|
||||||
val viewModel = LandingViewModel(SavedStateHandle())
|
val viewModel = LandingViewModel(SavedStateHandle())
|
||||||
|
viewModel.trySendAction(LandingAction.EmailInputChanged("input"))
|
||||||
viewModel.eventFlow.test {
|
viewModel.eventFlow.test {
|
||||||
viewModel.actionChannel.trySend(LandingAction.ContinueButtonClick)
|
viewModel.actionChannel.trySend(LandingAction.ContinueButtonClick)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
LandingEvent.NavigateToLogin(""),
|
LandingEvent.NavigateToLogin("input"),
|
||||||
awaitItem(),
|
awaitItem(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `ContinueButtonClick with empty input should do nothing`() = runTest {
|
||||||
|
val viewModel = LandingViewModel(SavedStateHandle())
|
||||||
|
viewModel.eventFlow.test {
|
||||||
|
viewModel.actionChannel.trySend(LandingAction.ContinueButtonClick)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `CreateAccountClick should emit NavigateToCreateAccount`() = runTest {
|
fun `CreateAccountClick should emit NavigateToCreateAccount`() = runTest {
|
||||||
val viewModel = LandingViewModel(SavedStateHandle())
|
val viewModel = LandingViewModel(SavedStateHandle())
|
||||||
|
|
Loading…
Reference in a new issue