Update the Send max access count logic (#557)

This commit is contained in:
David Perez authored and Álison Fernandes committed 2024-06-20 17:08:07 +01:00
1 parent 27ddac59b9
commit 49411f3e2f
4 files changed
+24 -26

No files matched your search

@@ -306,29 +306,6 @@ class AddSendScreenTest : BaseComposeTest() {
verify { viewModel.trySendAction(AddSendAction.MaxAccessCountChange(2)) }
}
@Test
fun `max access count decrement when set to 1 should do nothing`() =
runTest {
mutableStateFlow.update {
it.copy(
viewState = DEFAULT_VIEW_STATE.copy(
common = DEFAULT_COMMON_STATE.copy(maxAccessCount = 1),
),
)
}
// Expand options section:
composeTestRule
.onNodeWithText("Options")
.performScrollTo()
.performClick()
composeTestRule
.onNodeWithContentDescription("\u2212")
.performScrollTo()
.performClick()
verify(exactly = 0) { viewModel.trySendAction(any()) }
}
@Test
fun `on max access count increment should send MaxAccessCountChange`() = runTest {
// Expand options section:
@@ -287,7 +287,7 @@ class AddSendViewModelTest : BaseViewModelTest() {
}
@Test
fun `MaxAccessCountChange should update maxAccessCount`() = runTest {
fun `MaxAccessCountChange should update maxAccessCount to value when non-zero`() = runTest {
val viewModel = createViewModel()
val expectedViewState = DEFAULT_VIEW_STATE.copy(
common = DEFAULT_COMMON_STATE.copy(maxAccessCount = 5),
@@ -300,6 +300,25 @@ class AddSendViewModelTest : BaseViewModelTest() {
}
}
@Test
fun `MaxAccessCountChange should update maxAccessCount to null when zero`() = runTest {
val initialState = DEFAULT_STATE.copy(
viewState = DEFAULT_VIEW_STATE.copy(
common = DEFAULT_COMMON_STATE.copy(maxAccessCount = 5),
),
)
val expectedViewState = DEFAULT_VIEW_STATE.copy(
common = DEFAULT_COMMON_STATE.copy(maxAccessCount = null),
)
val viewModel = createViewModel(initialState)
viewModel.stateFlow.test {
assertEquals(initialState, awaitItem())
viewModel.trySendAction(AddSendAction.MaxAccessCountChange(0))
assertEquals(initialState.copy(viewState = expectedViewState), awaitItem())
}
}
@Test
fun `TextChange should update text input`() = runTest {
val viewModel = createViewModel()