Last active
September 17, 2021 09:32
-
-
Save adavis/5654c8356d61fbc8f919e3b7cfcd9717 to your computer and use it in GitHub Desktop.
Instrumentation tests for Jetpack Compose screen using Intents for navigation
This file contains 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
@ExperimentalAnimationApi | |
@RunWith(AndroidJUnit4::class) | |
class NonOrganizerTest { | |
@get:Rule | |
val composeTestRule = createAndroidComposeRule<MainActivity>() | |
@Before | |
fun goToNonOrganizerFragment() { | |
composeTestRule.activityRule.scenario.onActivity { | |
findNavController(it, R.id.nav_host_fragment).navigate(R.id.nonOrganizerFragment) | |
} | |
Intents.init() | |
} | |
@After | |
fun tearDown() { | |
Intents.release() | |
} | |
@Test | |
fun shouldDisplayStaticContent() { | |
listOf( | |
NON_ORGANIZER_MAIN_IMAGE, | |
NON_ORGANIZER_MAIN_TEXT, | |
NON_ORGANIZER_CONTACT_US, | |
NON_ORGANIZER_MEMBER_APP | |
).onEach { | |
composeTestRule.onNodeWithTag(it) | |
.assertIsDisplayed() | |
} | |
} | |
@Test | |
fun shouldGoToWeb_whenContactUsClicked() { | |
composeTestRule.onNodeWithTag(NON_ORGANIZER_CONTACT_US).performClick() | |
intended( | |
allOf( | |
hasAction(Intent.ACTION_VIEW), | |
hasData("https://help.meetup.com") | |
) | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment