From 6f524318b707797df789accedf92dd6d97603bd6 Mon Sep 17 00:00:00 2001 From: Andrew Haisting <142518658+ahaisting-livefront@users.noreply.github.com> Date: Tue, 5 Sep 2023 11:10:12 -0500 Subject: [PATCH] Cosmetic test fixes (#24) --- .../bitwarden/example/ExampleComposeTest.kt | 32 ------------------- .../bitwarden/example/ExampleJUnit5Test.kt | 18 ----------- ...apterTests.kt => ResultCallAdapterTest.kt} | 2 +- .../createaccount/CreateAccountScreenTest.kt | 2 +- .../CreateAccountViewModelTest.kt | 2 +- .../ui/feature/landing/LandingScreenTest.kt | 3 -- ...wModelTests.kt => RootNavViewModelTest.kt} | 2 +- 7 files changed, 4 insertions(+), 57 deletions(-) delete mode 100644 app/src/test/java/com/x8bit/bitwarden/example/ExampleComposeTest.kt delete mode 100644 app/src/test/java/com/x8bit/bitwarden/example/ExampleJUnit5Test.kt rename app/src/test/java/com/x8bit/bitwarden/example/{ResultCallAdapterTests.kt => ResultCallAdapterTest.kt} (97%) rename app/src/test/java/com/x8bit/bitwarden/example/ui/feature/rootnav/{RootNavViewModelTests.kt => RootNavViewModelTest.kt} (93%) diff --git a/app/src/test/java/com/x8bit/bitwarden/example/ExampleComposeTest.kt b/app/src/test/java/com/x8bit/bitwarden/example/ExampleComposeTest.kt deleted file mode 100644 index 4f71f23ff..000000000 --- a/app/src/test/java/com/x8bit/bitwarden/example/ExampleComposeTest.kt +++ /dev/null @@ -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) - } -} diff --git a/app/src/test/java/com/x8bit/bitwarden/example/ExampleJUnit5Test.kt b/app/src/test/java/com/x8bit/bitwarden/example/ExampleJUnit5Test.kt deleted file mode 100644 index d6e86d59a..000000000 --- a/app/src/test/java/com/x8bit/bitwarden/example/ExampleJUnit5Test.kt +++ /dev/null @@ -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(), emptyList()) - } - } -} diff --git a/app/src/test/java/com/x8bit/bitwarden/example/ResultCallAdapterTests.kt b/app/src/test/java/com/x8bit/bitwarden/example/ResultCallAdapterTest.kt similarity index 97% rename from app/src/test/java/com/x8bit/bitwarden/example/ResultCallAdapterTests.kt rename to app/src/test/java/com/x8bit/bitwarden/example/ResultCallAdapterTest.kt index 93aad4cff..f9e34fa4a 100644 --- a/app/src/test/java/com/x8bit/bitwarden/example/ResultCallAdapterTests.kt +++ b/app/src/test/java/com/x8bit/bitwarden/example/ResultCallAdapterTest.kt @@ -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 = diff --git a/app/src/test/java/com/x8bit/bitwarden/example/ui/feature/createaccount/CreateAccountScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/example/ui/feature/createaccount/CreateAccountScreenTest.kt index 6e0d393ba..fbd98766e 100644 --- a/app/src/test/java/com/x8bit/bitwarden/example/ui/feature/createaccount/CreateAccountScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/example/ui/feature/createaccount/CreateAccountScreenTest.kt @@ -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(relaxed = true) { every { eventFlow } returns emptyFlow() every { trySendAction(CreateAccountAction.SubmitClick) } returns Unit diff --git a/app/src/test/java/com/x8bit/bitwarden/example/ui/feature/createaccount/CreateAccountViewModelTest.kt b/app/src/test/java/com/x8bit/bitwarden/example/ui/feature/createaccount/CreateAccountViewModelTest.kt index aa66dc5e7..314265359 100644 --- a/app/src/test/java/com/x8bit/bitwarden/example/ui/feature/createaccount/CreateAccountViewModelTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/example/ui/feature/createaccount/CreateAccountViewModelTest.kt @@ -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) diff --git a/app/src/test/java/com/x8bit/bitwarden/example/ui/feature/landing/LandingScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/example/ui/feature/landing/LandingScreenTest.kt index ac8f4b263..0e0dec316 100644 --- a/app/src/test/java/com/x8bit/bitwarden/example/ui/feature/landing/LandingScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/example/ui/feature/landing/LandingScreenTest.kt @@ -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 diff --git a/app/src/test/java/com/x8bit/bitwarden/example/ui/feature/rootnav/RootNavViewModelTests.kt b/app/src/test/java/com/x8bit/bitwarden/example/ui/feature/rootnav/RootNavViewModelTest.kt similarity index 93% rename from app/src/test/java/com/x8bit/bitwarden/example/ui/feature/rootnav/RootNavViewModelTests.kt rename to app/src/test/java/com/x8bit/bitwarden/example/ui/feature/rootnav/RootNavViewModelTest.kt index c26c7c37e..46206de0b 100644 --- a/app/src/test/java/com/x8bit/bitwarden/example/ui/feature/rootnav/RootNavViewModelTests.kt +++ b/app/src/test/java/com/x8bit/bitwarden/example/ui/feature/rootnav/RootNavViewModelTest.kt @@ -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`() {