mirror of
https://github.com/bitwarden/android.git
synced 2026-11-19 17:40:12 -06:00
BIT-142: setup create account screen (#15)
This commit is contained in:
committed by
Álison Fernandes
parent
17d5475d0f
commit
a9aa2ea730
+29
@@ -0,0 +1,29 @@
|
||||
package com.x8bit.bitwarden.example.ui.feature.createaccount
|
||||
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.compose.ui.test.performClick
|
||||
import com.x8bit.bitwarden.example.ui.BaseComposeTest
|
||||
import com.x8bit.bitwarden.ui.feature.createaccount.CreateAccountAction
|
||||
import com.x8bit.bitwarden.ui.feature.createaccount.CreateAccountScreen
|
||||
import com.x8bit.bitwarden.ui.feature.createaccount.CreateAccountViewModel
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import kotlinx.coroutines.flow.emptyFlow
|
||||
import org.junit.Test
|
||||
|
||||
class CreateAccountScreenTest : BaseComposeTest() {
|
||||
|
||||
@Test
|
||||
fun `on submit click should send SubmitClick action`() {
|
||||
val viewModel = mockk<CreateAccountViewModel>(relaxed = true) {
|
||||
every { eventFlow } returns emptyFlow()
|
||||
every { trySendAction(CreateAccountAction.SubmitClick) } returns Unit
|
||||
}
|
||||
composeTestRule.setContent {
|
||||
CreateAccountScreen(viewModel)
|
||||
}
|
||||
composeTestRule.onNodeWithText("SUBMIT").performClick()
|
||||
verify { viewModel.trySendAction(CreateAccountAction.SubmitClick) }
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.x8bit.bitwarden.example.ui.feature.createaccount
|
||||
|
||||
import app.cash.turbine.test
|
||||
import com.x8bit.bitwarden.example.ui.BaseViewModelTest
|
||||
import com.x8bit.bitwarden.ui.feature.createaccount.CreateAccountAction
|
||||
import com.x8bit.bitwarden.ui.feature.createaccount.CreateAccountEvent
|
||||
import com.x8bit.bitwarden.ui.feature.createaccount.CreateAccountViewModel
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class CreateAccountViewModelTest : BaseViewModelTest() {
|
||||
|
||||
@Test
|
||||
fun `on SubmitClick should emit ShowToast`() = runTest {
|
||||
val viewModel = CreateAccountViewModel()
|
||||
viewModel.eventFlow.test {
|
||||
viewModel.actionChannel.trySend(CreateAccountAction.SubmitClick)
|
||||
assert(awaitItem() is CreateAccountEvent.ShowToast)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user