mirror of
https://github.com/bitwarden/android.git
synced 2026-06-01 18:26:31 -05:00
BIT-150: Add more comprehensive list of settings rows. (#155)
Co-authored-by: David Perez <david@livefront.com>
This commit is contained in:
@@ -13,10 +13,10 @@ import org.junit.Test
|
||||
class SettingsScreenTest : BaseComposeTest() {
|
||||
|
||||
@Test
|
||||
fun `on account row click should emit AccountSecurityClick`() {
|
||||
fun `on about row click should emit SettingsClick`() {
|
||||
val viewModel = mockk<SettingsViewModel> {
|
||||
every { eventFlow } returns emptyFlow()
|
||||
every { trySendAction(SettingsAction.AccountSecurityClick) } returns Unit
|
||||
every { trySendAction(SettingsAction.SettingsClick(Settings.ABOUT)) } returns Unit
|
||||
}
|
||||
composeTestRule.setContent {
|
||||
SettingsScreen(
|
||||
@@ -24,8 +24,90 @@ class SettingsScreenTest : BaseComposeTest() {
|
||||
onNavigateToAccountSecurity = { },
|
||||
)
|
||||
}
|
||||
composeTestRule.onNodeWithText("Account").performClick()
|
||||
verify { viewModel.trySendAction(SettingsAction.AccountSecurityClick) }
|
||||
composeTestRule.onNodeWithText("About").performClick()
|
||||
verify { viewModel.trySendAction(SettingsAction.SettingsClick(Settings.ABOUT)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on account security row click should emit SettingsClick`() {
|
||||
val viewModel = mockk<SettingsViewModel> {
|
||||
every { eventFlow } returns emptyFlow()
|
||||
every {
|
||||
trySendAction(SettingsAction.SettingsClick(Settings.ACCOUNT_SECURITY))
|
||||
} returns Unit
|
||||
}
|
||||
composeTestRule.setContent {
|
||||
SettingsScreen(
|
||||
viewModel = viewModel,
|
||||
onNavigateToAccountSecurity = { },
|
||||
)
|
||||
}
|
||||
composeTestRule.onNodeWithText("Security").performClick()
|
||||
verify { viewModel.trySendAction(SettingsAction.SettingsClick(Settings.ACCOUNT_SECURITY)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on appearance row click should emit SettingsClick`() {
|
||||
val viewModel = mockk<SettingsViewModel> {
|
||||
every { eventFlow } returns emptyFlow()
|
||||
every { trySendAction(SettingsAction.SettingsClick(Settings.APPEARANCE)) } returns Unit
|
||||
}
|
||||
composeTestRule.setContent {
|
||||
SettingsScreen(
|
||||
viewModel = viewModel,
|
||||
onNavigateToAccountSecurity = { },
|
||||
)
|
||||
}
|
||||
composeTestRule.onNodeWithText("Language").performClick()
|
||||
verify { viewModel.trySendAction(SettingsAction.SettingsClick(Settings.APPEARANCE)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on auto-fill row click should emit SettingsClick`() {
|
||||
val viewModel = mockk<SettingsViewModel> {
|
||||
every { eventFlow } returns emptyFlow()
|
||||
every { trySendAction(SettingsAction.SettingsClick(Settings.AUTO_FILL)) } returns Unit
|
||||
}
|
||||
composeTestRule.setContent {
|
||||
SettingsScreen(
|
||||
viewModel = viewModel,
|
||||
onNavigateToAccountSecurity = { },
|
||||
)
|
||||
}
|
||||
composeTestRule.onNodeWithText("Auto-fill").performClick()
|
||||
verify { viewModel.trySendAction(SettingsAction.SettingsClick(Settings.AUTO_FILL)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on other row click should emit SettingsClick`() {
|
||||
val viewModel = mockk<SettingsViewModel> {
|
||||
every { eventFlow } returns emptyFlow()
|
||||
every { trySendAction(SettingsAction.SettingsClick(Settings.OTHER)) } returns Unit
|
||||
}
|
||||
composeTestRule.setContent {
|
||||
SettingsScreen(
|
||||
viewModel = viewModel,
|
||||
onNavigateToAccountSecurity = { },
|
||||
)
|
||||
}
|
||||
composeTestRule.onNodeWithText("Other").performClick()
|
||||
verify { viewModel.trySendAction(SettingsAction.SettingsClick(Settings.OTHER)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on vault row click should emit SettingsClick`() {
|
||||
val viewModel = mockk<SettingsViewModel> {
|
||||
every { eventFlow } returns emptyFlow()
|
||||
every { trySendAction(SettingsAction.SettingsClick(Settings.VAULT)) } returns Unit
|
||||
}
|
||||
composeTestRule.setContent {
|
||||
SettingsScreen(
|
||||
viewModel = viewModel,
|
||||
onNavigateToAccountSecurity = { },
|
||||
)
|
||||
}
|
||||
composeTestRule.onNodeWithText("Vaults").performClick()
|
||||
verify { viewModel.trySendAction(SettingsAction.SettingsClick(Settings.VAULT)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -9,11 +9,56 @@ import org.junit.jupiter.api.Test
|
||||
class SettingsViewModelTest : BaseViewModelTest() {
|
||||
|
||||
@Test
|
||||
fun `on AccountSecurityClick should emit NavigateAccountSecurity`() = runTest {
|
||||
fun `on SettingsClick with ABOUT should emit nothing`() = runTest {
|
||||
val viewModel = SettingsViewModel()
|
||||
viewModel.eventFlow.test {
|
||||
viewModel.trySendAction(SettingsAction.AccountSecurityClick)
|
||||
viewModel.trySendAction(SettingsAction.SettingsClick(Settings.ABOUT))
|
||||
expectNoEvents()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on SettingsClick with ACCOUNT_SECURITY should emit NavigateAccountSecurity`() = runTest {
|
||||
val viewModel = SettingsViewModel()
|
||||
viewModel.eventFlow.test {
|
||||
viewModel.trySendAction(SettingsAction.SettingsClick(Settings.ACCOUNT_SECURITY))
|
||||
assertEquals(SettingsEvent.NavigateAccountSecurity, awaitItem())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on SettingsClick with APPEARANCE should emit nothing`() = runTest {
|
||||
val viewModel = SettingsViewModel()
|
||||
viewModel.eventFlow.test {
|
||||
viewModel.trySendAction(SettingsAction.SettingsClick(Settings.APPEARANCE))
|
||||
expectNoEvents()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on SettingsClick with AUTO_FILL should emit nothing`() = runTest {
|
||||
val viewModel = SettingsViewModel()
|
||||
viewModel.eventFlow.test {
|
||||
viewModel.trySendAction(SettingsAction.SettingsClick(Settings.AUTO_FILL))
|
||||
expectNoEvents()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on SettingsClick with OTHER should emit nothing`() = runTest {
|
||||
val viewModel = SettingsViewModel()
|
||||
viewModel.eventFlow.test {
|
||||
viewModel.trySendAction(SettingsAction.SettingsClick(Settings.OTHER))
|
||||
expectNoEvents()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on SettingsClick with VAULT should emit nothing`() = runTest {
|
||||
val viewModel = SettingsViewModel()
|
||||
viewModel.eventFlow.test {
|
||||
viewModel.trySendAction(SettingsAction.SettingsClick(Settings.VAULT))
|
||||
expectNoEvents()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user