Skip to content

Commit

Permalink
ANDROID-15138 Fix click on clear input test
Browse files Browse the repository at this point in the history
  • Loading branch information
yamal-alm committed Sep 9, 2024
1 parent 5786866 commit 835c121
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ import com.telefonica.mistica.testutils.ScreenshotsTest
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.mock
import org.mockito.kotlin.verify
import org.robolectric.RobolectricTestRunner

@RunWith(RobolectricTestRunner::class)
class SearchInputTest : ScreenshotsTest() {

private val onValueChangeMock: (String) -> Unit = mock()

@get:Rule
val composeTestRule = createComposeRule()

Expand Down Expand Up @@ -44,15 +49,15 @@ class SearchInputTest : ScreenshotsTest() {

whenClickingOnClearSearch()

thenScreenshotIsOk()
thenValueIsNowEmptyString()
}

private fun givenSomeSearchInput(value: String, enabled: Boolean = true) {
composeTestRule.setContent {
MisticaTheme(brand = MovistarBrand) {
SearchInput(
value = value,
onValueChange = { },
onValueChange = onValueChangeMock,
label = "Search something",
enabled = enabled
)
Expand All @@ -67,4 +72,8 @@ class SearchInputTest : ScreenshotsTest() {
private fun thenScreenshotIsOk() {
compareScreenshot(composeTestRule.onRoot())
}

private fun thenValueIsNowEmptyString() {
verify(onValueChangeMock).invoke("")
}
}

0 comments on commit 835c121

Please sign in to comment.