Skip to content

Instantly share code, notes, and snippets.

@eevajonnapanula
Created June 3, 2024 03:39
Show Gist options
  • Save eevajonnapanula/e029a258a473307fd1d2fd0d8a737d30 to your computer and use it in GitHub Desktop.
Save eevajonnapanula/e029a258a473307fd1d2fd0d8a737d30 to your computer and use it in GitHub Desktop.
class ToggleableTest {
@get:Rule
val composeTestRule = createComposeRule()
@Test
fun hasRoleNameValue() {
composeTestRule.setContent {
ModifiersExampleTheme {
ToggleableScreen()
}
}
val toggleableElement =
composeTestRule.onNode(hasTestTag("accessible-toggle"))
// Assert accessible name
toggleableElement.assertTextEquals("Toggleable")
// Assert role
toggleableElement.assertIsToggleable()
// Assert value
toggleableElement.assertIsOff()
toggleableElement.performClick()
toggleableElement.assertIsOn()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment