mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 11:47:04 +05:30
paparazzi-tests: move to common module
This commit is contained in:
parent
60e9c8c625
commit
cbdfa67d07
11 changed files with 7 additions and 36 deletions
|
@ -8,6 +8,7 @@ plugins {
|
|||
id("dev.msfjarvis.claw.kotlin-common")
|
||||
id("dev.msfjarvis.claw.android-library")
|
||||
alias(libs.plugins.aurora.svg.transcoder)
|
||||
alias(libs.plugins.paparazzi)
|
||||
}
|
||||
|
||||
val transcodeTask =
|
||||
|
@ -38,6 +39,12 @@ dependencies {
|
|||
implementation(libs.compose.richtext.ui)
|
||||
implementation(libs.kotlinx.coroutines.core)
|
||||
implementation(libs.kotlinx.datetime)
|
||||
testImplementation(kotlin("test-junit"))
|
||||
testImplementation(libs.testparameterinjector)
|
||||
}
|
||||
|
||||
tasks.withType<Test>().configureEach {
|
||||
javaLauncher.set(javaToolchains.launcherFor { languageVersion.set(JavaLanguageVersion.of(11)) })
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package dev.msfjarvis.claw.android.tests
|
||||
|
||||
import app.cash.paparazzi.Paparazzi
|
||||
import com.google.testing.junit.testparameterinjector.TestParameter
|
||||
import com.google.testing.junit.testparameterinjector.TestParameterInjector
|
||||
import org.junit.Rule
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
/** Base class for Paparazzi based tests that handles parameterization based on [Theme]. */
|
||||
@RunWith(TestParameterInjector::class)
|
||||
abstract class BasePaparazziTest {
|
||||
@get:Rule val paparazzi = Paparazzi()
|
||||
@TestParameter lateinit var theme: Theme
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package dev.msfjarvis.claw.android.tests
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import dev.msfjarvis.claw.common.posts.LobstersCard
|
||||
import dev.msfjarvis.claw.common.posts.PostActions
|
||||
import dev.msfjarvis.claw.database.local.SavedPost
|
||||
import org.junit.Test
|
||||
|
||||
class LobstersCardTest : BasePaparazziTest() {
|
||||
companion object {
|
||||
private val post =
|
||||
SavedPost(
|
||||
shortId = "shortId",
|
||||
title = "Title",
|
||||
url = "/s/shortId",
|
||||
createdAt = "2021-04-03T16:16:02.000-05:00",
|
||||
commentCount = 10,
|
||||
commentsUrl = "/s/shortId",
|
||||
submitterName = "msfjarvis",
|
||||
submitterAvatarUrl = "/msfjarvis.png",
|
||||
tags = listOf("science", "technology"),
|
||||
)
|
||||
private val postActions =
|
||||
object : PostActions {
|
||||
override fun viewPost(postUrl: String, commentsUrl: String) {}
|
||||
|
||||
override fun viewComments(postId: String) {}
|
||||
|
||||
override fun viewCommentsPage(commentsUrl: String) {}
|
||||
|
||||
override fun toggleSave(post: SavedPost) {}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun verify() {
|
||||
paparazzi.snapshot {
|
||||
MaterialTheme(colorScheme = theme.colors) { LobstersCard(post, false, postActions) }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package dev.msfjarvis.claw.android.tests
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import dev.msfjarvis.claw.common.ui.decorations.MonthHeader
|
||||
import kotlinx.datetime.Month
|
||||
import org.junit.Test
|
||||
|
||||
class MonthHeaderTest : BasePaparazziTest() {
|
||||
@Test
|
||||
fun verify() {
|
||||
paparazzi.snapshot { MaterialTheme(colorScheme = theme.colors) { MonthHeader(Month.APRIL) } }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package dev.msfjarvis.claw.android.tests
|
||||
|
||||
import androidx.compose.material3.ColorScheme
|
||||
import dev.msfjarvis.claw.common.theme.DarkThemeColors
|
||||
import dev.msfjarvis.claw.common.theme.LightThemeColors
|
||||
|
||||
enum class Theme(val colors: ColorScheme) {
|
||||
Light(LightThemeColors),
|
||||
Dark(DarkThemeColors),
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
Binary file not shown.
After Width: | Height: | Size: 7.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 8.3 KiB |
Loading…
Add table
Add a link
Reference in a new issue