BIT-970: Ensure Terms of Service switch reads off checked state (#171)

This commit is contained in:
Brian Yencho
2023-10-27 11:27:03 -05:00
committed by GitHub
parent 6b78f7b1a9
commit 75c8bb2920
2 changed files with 31 additions and 0 deletions

View File

@@ -4,6 +4,8 @@ import android.content.Intent
import android.net.Uri
import androidx.compose.ui.test.assertCountEquals
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsOff
import androidx.compose.ui.test.assertIsOn
import androidx.compose.ui.test.filterToOne
import androidx.compose.ui.test.hasAnyAncestor
import androidx.compose.ui.test.isDialog
@@ -96,6 +98,32 @@ class CreateAccountScreenTest : BaseComposeTest() {
verify { viewModel.trySendAction(CheckDataBreachesToggle(true)) }
}
@Test
fun `accept policies should be toggled on or off according to the state`() {
val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
val viewModel = mockk<CreateAccountViewModel>(relaxed = true) {
every { stateFlow } returns mutableStateFlow
every { eventFlow } returns emptyFlow()
every { trySendAction(AcceptPoliciesToggle(true)) } returns Unit
}
composeTestRule.setContent {
CreateAccountScreen(
onNavigateBack = {},
onNavigateToLogin = { _, _ -> },
viewModel = viewModel,
)
}
composeTestRule
.onNodeWithText("By activating this switch you agree", substring = true)
.assertIsOff()
mutableStateFlow.update { it.copy(isAcceptPoliciesToggled = true) }
composeTestRule
.onNodeWithText("By activating this switch you agree", substring = true)
.assertIsOn()
}
@Test
fun `accept policies click should send AcceptPoliciesToggle action`() {
val viewModel = mockk<CreateAccountViewModel>(relaxed = true) {