Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 303a8f94 authored by Wolf-Martell Montwé's avatar Wolf-Martell Montwé
Browse files

Change back to not change state and instead navigate back immediately

parent 4c7b6366
Loading
Loading
Loading
Loading
+1 −15
Original line number Diff line number Diff line
@@ -110,22 +110,8 @@ internal class AccountValidationViewModel(
    }

    private fun onBack() {
        if (state.value.isSuccess) {
            updateState {
                it.copy(
                    isSuccess = false,
                )
            }
        } else if (state.value.error != null) {
            updateState {
                it.copy(
                    error = null,
                )
            }
        } else {
        navigateBack()
    }
    }

    private fun onRetry() {
        updateState {
+0 −32
Original line number Diff line number Diff line
@@ -163,38 +163,6 @@ class AccountValidationViewModelTest {
        }
    }

    @Test
    fun `should clear isSuccess when OnBackClicked event received when in success state`() = runTest {
        val initialState = State(isSuccess = true)
        val testSubject = createTestSubject(initialState = initialState)
        val turbines = turbinesWithInitialStateCheck(testSubject, initialState)

        testSubject.event(Event.OnBackClicked)

        assertThatAndMviTurbinesConsumed(
            actual = turbines.stateTurbine.awaitItem(),
            turbines = turbines,
        ) {
            isEqualTo(initialState.copy(isSuccess = false))
        }
    }

    @Test
    fun `should clear error when OnBackClicked event received when in error state`() = runTest {
        val initialState = State(error = Error.ServerError("server error"))
        val testSubject = createTestSubject(initialState = initialState)
        val turbines = turbinesWithInitialStateCheck(testSubject, initialState)

        testSubject.event(Event.OnBackClicked)

        assertThatAndMviTurbinesConsumed(
            actual = turbines.stateTurbine.awaitItem(),
            turbines = turbines,
        ) {
            isEqualTo(initialState.copy(error = null))
        }
    }

    @Test
    fun `should clear error and trigger check settings when OnRetryClicked event received`() = runTest {
        val initialState = State(