mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-17 23:47:02 +05:30
Add tests for LobstersTopAppBar
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
83af1e1c53
commit
eee0737a1c
5 changed files with 74 additions and 0 deletions
Binary file not shown.
After Width: | Height: | Size: 6.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 6.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 8 KiB |
Binary file not shown.
After Width: | Height: | Size: 7.9 KiB |
|
@ -0,0 +1,74 @@
|
||||||
|
package dev.msfjarvis.lobsters.ui.main
|
||||||
|
|
||||||
|
import androidx.compose.ui.graphics.asAndroidBitmap
|
||||||
|
import androidx.compose.ui.test.captureToImage
|
||||||
|
import androidx.compose.ui.test.junit4.createComposeRule
|
||||||
|
import androidx.compose.ui.test.onRoot
|
||||||
|
import com.karumi.shot.ScreenshotTest
|
||||||
|
import dev.msfjarvis.lobsters.ui.DarkTestTheme
|
||||||
|
import dev.msfjarvis.lobsters.ui.LightTestTheme
|
||||||
|
import dev.msfjarvis.lobsters.ui.navigation.Destination
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class LobstersTopBarTest : ScreenshotTest {
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
val composeTestRule = createComposeRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showsRefreshIconWhenOnHottestPostsScreen_DarkTheme() {
|
||||||
|
composeTestRule.setContent {
|
||||||
|
DarkTestTheme {
|
||||||
|
LobstersTopBar(
|
||||||
|
currentDestination = Destination.Hottest,
|
||||||
|
reloadPosts = { /*TODO*/ }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compareScreenshot(composeTestRule.onRoot().captureToImage().asAndroidBitmap())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showsRefreshIconWhenOnHottestPostsScreen_LightTheme() {
|
||||||
|
composeTestRule.setContent {
|
||||||
|
LightTestTheme {
|
||||||
|
LobstersTopBar(
|
||||||
|
currentDestination = Destination.Hottest,
|
||||||
|
reloadPosts = { /*TODO*/ }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compareScreenshot(composeTestRule.onRoot().captureToImage().asAndroidBitmap())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun doesNotShowRefreshIconWhenOnSavedPostsScreen_DarkTheme() {
|
||||||
|
composeTestRule.setContent {
|
||||||
|
DarkTestTheme {
|
||||||
|
LobstersTopBar(
|
||||||
|
currentDestination = Destination.Saved,
|
||||||
|
reloadPosts = { /*TODO*/ }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compareScreenshot(composeTestRule.onRoot().captureToImage().asAndroidBitmap())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun doesNotShowRefreshIconWhenOnSavedPostsScreen_LightTheme() {
|
||||||
|
composeTestRule.setContent {
|
||||||
|
LightTestTheme {
|
||||||
|
LobstersTopBar(
|
||||||
|
currentDestination = Destination.Saved,
|
||||||
|
reloadPosts = { /*TODO*/ }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compareScreenshot(composeTestRule.onRoot().captureToImage().asAndroidBitmap())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue