Skip to content

Commit

Permalink
BIT-589 Prevent crash on Landing when navigating with empty input (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahaisting-livefront authored and vvolkgang committed Jun 20, 2024
1 parent 3de916c commit 3548340
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class LandingViewModel @Inject constructor(
}

private fun handleContinueButtonClicked() {
// TODO: add actual validation here: BIT-193
if (mutableStateFlow.value.emailInput.isBlank()) {
return
}
sendEvent(LandingEvent.NavigateToLogin(mutableStateFlow.value.emailInput))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,24 @@ class LandingViewModelTest : BaseViewModelTest() {
@Test
fun `ContinueButtonClick should emit NavigateToLogin`() = runTest {
val viewModel = LandingViewModel(SavedStateHandle())
viewModel.trySendAction(LandingAction.EmailInputChanged("input"))
viewModel.eventFlow.test {
viewModel.actionChannel.trySend(LandingAction.ContinueButtonClick)
assertEquals(
LandingEvent.NavigateToLogin(""),
LandingEvent.NavigateToLogin("input"),
awaitItem(),
)
}
}

@Test
fun `ContinueButtonClick with empty input should do nothing`() = runTest {
val viewModel = LandingViewModel(SavedStateHandle())
viewModel.eventFlow.test {
viewModel.actionChannel.trySend(LandingAction.ContinueButtonClick)
}
}

@Test
fun `CreateAccountClick should emit NavigateToCreateAccount`() = runTest {
val viewModel = LandingViewModel(SavedStateHandle())
Expand Down

0 comments on commit 3548340

Please sign in to comment.