diff --git a/library/screenshots/SearchInput_is_cleared_when_clicking_on_clear_search_button.png b/library/screenshots/SearchInput_is_cleared_when_clicking_on_clear_search_button.png deleted file mode 100644 index 8f523f08e..000000000 Binary files a/library/screenshots/SearchInput_is_cleared_when_clicking_on_clear_search_button.png and /dev/null differ diff --git a/library/src/test/java/com/telefonica/mistica/compose/input/SearchInputTest.kt b/library/src/test/java/com/telefonica/mistica/compose/input/SearchInputTest.kt index 38f9a156f..a60f22a4a 100644 --- a/library/src/test/java/com/telefonica/mistica/compose/input/SearchInputTest.kt +++ b/library/src/test/java/com/telefonica/mistica/compose/input/SearchInputTest.kt @@ -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() @@ -44,7 +49,7 @@ class SearchInputTest : ScreenshotsTest() { whenClickingOnClearSearch() - thenScreenshotIsOk() + thenValueIsNowEmptyString() } private fun givenSomeSearchInput(value: String, enabled: Boolean = true) { @@ -52,7 +57,7 @@ class SearchInputTest : ScreenshotsTest() { MisticaTheme(brand = MovistarBrand) { SearchInput( value = value, - onValueChange = { }, + onValueChange = onValueChangeMock, label = "Search something", enabled = enabled ) @@ -67,4 +72,8 @@ class SearchInputTest : ScreenshotsTest() { private fun thenScreenshotIsOk() { compareScreenshot(composeTestRule.onRoot()) } + + private fun thenValueIsNowEmptyString() { + verify(onValueChangeMock).invoke("") + } }