Created
March 17, 2021 17:06
-
-
Save igorescodro/893133fc0ffd85b28e2c371974784fb3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class MyComposableTest { | |
@get:Rule | |
val composeTestRule = createComposeRule() | |
@Test | |
fun test_TitleIsShownWhenLoaded() { | |
initComposable(state = MyState.Loaded) | |
composeTestRule.onNodeWithText("Title").assertIsDisplayed() | |
} | |
@Test | |
fun test_TitleIsNotShownWhenError() { | |
initComposable(state = MyState.Error) | |
composeTestRule.onNodeWithText("Title").assertIsNotDisplayed() | |
} | |
private fun initComposable(state: MyState) { | |
composeTestRule.setContent { | |
MyTheme { | |
MyComposable(state = state) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment