Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANDROID-15138 Search Input in compose #380

Merged
merged 11 commits into from
Sep 10, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ fun Inputs() {
Title("Disable Dropdown")
DropDownSample(enabled = false)
Title("Search Input")
SearchInputSample()
SearchInputSample(enabled = true)
SearchInputSample(enabled = false)
Title("Inverse inputs")
Column(
modifier = Modifier
Expand Down Expand Up @@ -450,7 +451,7 @@ private fun DropDownSample(enabled: Boolean = true) {
}

@Composable
private fun SearchInputSample() {
private fun SearchInputSample(enabled: Boolean) {
var text by remember {
mutableStateOf("")
}
Expand All @@ -464,6 +465,7 @@ private fun SearchInputSample() {
onValueChange = {
text = it
},
label = "Search Something"
label = "Search Something",
enabled = enabled,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ class SearchInputTest : ScreenshotsTest() {
thenScreenshotIsOk()
}

@Test
fun `disabled SearchInput`() {
givenSomeSearchInput(value = "", enabled = false)

thenScreenshotIsOk()
}

@Test
fun `SearchInput is cleared when clicking on clear search button`() {
givenSomeSearchInput(value = "Something")
Expand All @@ -40,13 +47,14 @@ class SearchInputTest : ScreenshotsTest() {
thenScreenshotIsOk()
}

private fun givenSomeSearchInput(value: String) {
private fun givenSomeSearchInput(value: Strin, enabled: Boolean = true) {
yamal-alm marked this conversation as resolved.
Show resolved Hide resolved
composeTestRule.setContent {
MisticaTheme(brand = MovistarBrand) {
SearchInput(
value = value,
onValueChange = { },
label = "Search something",
enabled = enabled
)
}
}
Expand Down
Loading