Hi. I'm using an IconButton to show a `DropdownMe...
# compose
a
Hi. I'm using an IconButton to show a
DropdownMenu
, how can I test it? at least test that some child is shown, or whole dropdown
Copy code
@Composable
fun OverflowIcon(showMenu: Boolean, onClick: (Boolean) -> Unit) {
    IconButton(onClick = { onClick(!showMenu) }) {
        Icon(
            imageVector = Icons.Default.MoreVert,
            contentDescription = stringResource(
                id = R.string.top_bar_menu_icon_content_description
            )
        )
    }

    DropdownMenu(
        expanded = showMenu,
        onDismissRequest = { onClick(!showMenu) }
    ) {
        DropdownMenuItem(onClick = {}) {
            Text(
                text = stringResource(
                    id = R.string.top_bar_menu_log_out
                )
            )
        }
    }
}
I've tried to do:
Copy code
@Test
    fun topBarMenuIconClick_showMenu() {
        composeTestRule.setThemeContent {
            DashboardTopBar(titleRes = R.string.weather_title)
        }

        val menuIcon = composeTestRule.activity.getString(
            R.string.top_bar_menu_icon_content_description
        )

        val menuLogOut = composeTestRule.activity.getString(
            R.string.top_bar_menu_log_out
        )

        composeTestRule.onNodeWithContentDescription(menuIcon).onParent().performClick()
        composeTestRule.onRoot(useUnmergedTree = true).assert(hasText(menuLogOut)).assertExists()

    }
but not seems to work