Cosmetic test fixes (#24)

This commit is contained in:
Andrew Haisting 2023-09-05 11:10:12 -05:00 committed by Álison Fernandes
parent 915e9d5fd6
commit 6f524318b7
7 changed files with 4 additions and 57 deletions

View file

@ -1,32 +0,0 @@
package com.x8bit.bitwarden.example
import androidx.compose.material3.Button
import androidx.compose.ui.test.onRoot
import androidx.compose.ui.test.performClick
import com.x8bit.bitwarden.example.ui.BaseComposeTest
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
/**
* Example showing that Compose tests using "junit" imports and Robolectric work.
*/
class ExampleComposeTest : BaseComposeTest() {
@Test
fun `the onClick callback should be correctly triggered when performing a click`() {
var isClicked = false
composeTestRule.setContent {
Button(
onClick = { isClicked = true },
) {
// Empty
}
}
assertFalse(isClicked)
composeTestRule.onRoot().performClick()
assertTrue(isClicked)
}
}

View file

@ -1,18 +0,0 @@
package com.x8bit.bitwarden.example
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
/**
* Example showing that JUnit5 tests using "jupiter" imports work.
*/
class ExampleJUnit5Test {
@Nested
inner class NestedSample {
@Test
fun `an empty listOf should be the same as emptyList`() {
assertEquals(listOf<Any>(), emptyList<Any>())
}
}
}

View file

@ -11,7 +11,7 @@ import retrofit2.Retrofit
import retrofit2.create
import retrofit2.http.GET
class ResultCallAdapterTests {
class ResultCallAdapterTest {
private val server: MockWebServer = MockWebServer().apply { start() }
private val testService: FakeService =

View file

@ -15,7 +15,7 @@ import org.junit.Test
class CreateAccountScreenTest : BaseComposeTest() {
@Test
fun `on submit click should send SubmitClick action`() {
fun `submit click should send SubmitClick action`() {
val viewModel = mockk<CreateAccountViewModel>(relaxed = true) {
every { eventFlow } returns emptyFlow()
every { trySendAction(CreateAccountAction.SubmitClick) } returns Unit

View file

@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test
class CreateAccountViewModelTest : BaseViewModelTest() {
@Test
fun `on SubmitClick should emit ShowToast`() = runTest {
fun `SubmitClick should emit ShowToast`() = runTest {
val viewModel = CreateAccountViewModel()
viewModel.eventFlow.test {
viewModel.actionChannel.trySend(CreateAccountAction.SubmitClick)

View file

@ -14,9 +14,6 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.emptyFlow
import org.junit.Test
/**
* Example showing that Compose tests using "junit" imports and Robolectric work.
*/
class LandingScreenTest : BaseComposeTest() {
@Test

View file

@ -7,7 +7,7 @@ import com.x8bit.bitwarden.ui.feature.rootnav.RootNavViewModel
import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.Test
class RootNavViewModelTests : BaseViewModelTest() {
class RootNavViewModelTest : BaseViewModelTest() {
@Test
fun `initial state should be splash`() {