-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
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
45 changes: 45 additions & 0 deletions
45
app/src/androidTest/java/app/jopiter/navigation/JopiterTopBarTest.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package app.jopiter.navigation | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.assertTextEquals | ||
import androidx.compose.ui.test.junit4.ComposeTestRule | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import androidx.compose.ui.test.performClick | ||
import org.junit.Assert | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class JopiterTopBarTest { | ||
|
||
@get:Rule | ||
val composeRule = createComposeRule() | ||
|
||
private var clickCount = 0 | ||
|
||
@Before | ||
fun setContent() { | ||
composeRule.setContent { | ||
JopiterTopBar { clickCount++ } | ||
} | ||
} | ||
|
||
|
||
@Test | ||
fun should_include_app_name_in_top_bar() { | ||
composeRule.barTitle().assertIsDisplayed().assertTextEquals("Jopiter") | ||
} | ||
|
||
@Test | ||
fun should_run_on_click_when_clicking_navigation_button() { | ||
composeRule.barIcon().performClick() | ||
assertEquals(1, clickCount) | ||
composeRule.barIcon().performClick() | ||
assertEquals(2, clickCount) | ||
} | ||
|
||
private fun ComposeTestRule.barTitle() = onNodeWithTag("top_app_bar_title") | ||
private fun ComposeTestRule.barIcon() = onNodeWithTag("top_app_bar_icon") | ||
} |
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
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