diff --git a/prices/build.gradle.kts b/prices/build.gradle.kts index 57e63ffc..8f745405 100644 --- a/prices/build.gradle.kts +++ b/prices/build.gradle.kts @@ -3,9 +3,11 @@ plugins { id("kotlin-android") id("VitaminComposeLibraryPlugin") id("com.vanniktech.maven.publish") + id("app.cash.paparazzi") } dependencies { api(project(":foundation:foundation")) implementation(AndroidX.compose.ui.tooling) + testImplementation("com.google.testparameterinjector:test-parameter-injector:1.8") } diff --git a/prices/src/test/kotlin/com/decathlon/vitamin/compose/prices/VitaminPricesPrimaryTest.kt b/prices/src/test/kotlin/com/decathlon/vitamin/compose/prices/VitaminPricesPrimaryTest.kt new file mode 100644 index 00000000..6067b236 --- /dev/null +++ b/prices/src/test/kotlin/com/decathlon/vitamin/compose/prices/VitaminPricesPrimaryTest.kt @@ -0,0 +1,92 @@ +package com.decathlon.vitamin.compose.prices + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.padding +import androidx.compose.material.Scaffold +import androidx.compose.material.Text +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.vector.rememberVectorPainter +import androidx.compose.ui.unit.dp +import app.cash.paparazzi.Paparazzi +import com.decathlon.vitamin.compose.foundation.VitaminTheme +import com.decathlon.vitamin.compose.prices.utils.PriceVariantsFactory +import com.decathlon.vitamin.compose.prices.utils.Theme +import com.decathlon.vitamin.compose.prices.utils.Variant +import com.google.testing.junit.testparameterinjector.TestParameter +import com.google.testing.junit.testparameterinjector.TestParameterInjector +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + + +@RunWith(TestParameterInjector::class) +class VitaminPricesPrimaryTest( + @TestParameter val variant: Variant +) { + @get:Rule + val paparazzi = Paparazzi() + + @Test + fun small(@TestParameter theme: Theme) { + paparazzi.snapshot { + VitaminTheme(theme == Theme.Dark) { + Scaffold { padding -> + Column( + modifier = Modifier.padding(padding), + verticalArrangement = Arrangement.spacedBy(8.dp) + ) { + Text(text = variant.name, style = VitaminTheme.typography.subtitle1) + PriceVariantsFactory.Price( + variant = variant, + size = VitaminPriceSizes.small() + ) + } + } + } + } + } + + @Test + fun medium(@TestParameter theme: Theme) { + paparazzi.snapshot { + VitaminTheme(theme == Theme.Dark) { + Scaffold { padding -> + Column( + modifier = Modifier.padding(padding), + verticalArrangement = Arrangement.spacedBy(8.dp) + ) { + Text(text = variant.name, style = VitaminTheme.typography.subtitle1) + PriceVariantsFactory.Price( + variant = variant, + size = VitaminPriceSizes.medium() + ) + } + } + } + } + } + + @Test + fun large(@TestParameter theme: Theme) { + paparazzi.snapshot { + VitaminTheme(theme == Theme.Dark) { + Scaffold { padding -> + Column( + modifier = Modifier.padding(padding), + verticalArrangement = Arrangement.spacedBy(8.dp) + ) { + Text(text = variant.name, style = VitaminTheme.typography.subtitle1) + PriceVariantsFactory.Price( + variant = variant, + size = VitaminPriceSizes.large() + ) + } + } + } + } + } + +} diff --git a/prices/src/test/kotlin/com/decathlon/vitamin/compose/prices/utils/PriceVariantsFactory.kt b/prices/src/test/kotlin/com/decathlon/vitamin/compose/prices/utils/PriceVariantsFactory.kt new file mode 100644 index 00000000..f158339d --- /dev/null +++ b/prices/src/test/kotlin/com/decathlon/vitamin/compose/prices/utils/PriceVariantsFactory.kt @@ -0,0 +1,41 @@ +package com.decathlon.vitamin.compose.prices.utils + +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import com.decathlon.vitamin.compose.prices.PriceSizes +import com.decathlon.vitamin.compose.prices.VitaminPrices + +object PriceVariantsFactory { + + @Suppress("LongMethod") + @Composable + fun Price( + variant: Variant, + size: PriceSizes, + modifier: Modifier = Modifier, + text: String = "250,00 €" + ) { + when (variant) { + Variant.Default -> VitaminPrices.Default( + modifier = modifier, + sizes = size, + text = text + ) + Variant.Alert -> VitaminPrices.Alert( + modifier = modifier, + sizes = size, + text = text + ) + Variant.Accent -> VitaminPrices.Accent( + modifier = modifier, + sizes = size, + text = text + ) + Variant.Strikethrough -> VitaminPrices.Strikethrough( + modifier = modifier, + sizes = size, + text = text + ) + } + } +} diff --git a/prices/src/test/kotlin/com/decathlon/vitamin/compose/prices/utils/Theme.kt b/prices/src/test/kotlin/com/decathlon/vitamin/compose/prices/utils/Theme.kt new file mode 100644 index 00000000..6c50db6a --- /dev/null +++ b/prices/src/test/kotlin/com/decathlon/vitamin/compose/prices/utils/Theme.kt @@ -0,0 +1,3 @@ +package com.decathlon.vitamin.compose.prices.utils + +enum class Theme { Light, Dark } diff --git a/prices/src/test/kotlin/com/decathlon/vitamin/compose/prices/utils/Variant.kt b/prices/src/test/kotlin/com/decathlon/vitamin/compose/prices/utils/Variant.kt new file mode 100644 index 00000000..d8ca24c4 --- /dev/null +++ b/prices/src/test/kotlin/com/decathlon/vitamin/compose/prices/utils/Variant.kt @@ -0,0 +1,5 @@ +package com.decathlon.vitamin.compose.prices.utils + +enum class Variant { + Default, Accent, Alert, Strikethrough +} diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Accent,Dark].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Accent,Dark].png new file mode 100644 index 00000000..051bb236 Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Accent,Dark].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Accent,Light].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Accent,Light].png new file mode 100644 index 00000000..12c153d8 Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Accent,Light].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Alert,Dark].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Alert,Dark].png new file mode 100644 index 00000000..29d1dc55 Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Alert,Dark].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Alert,Light].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Alert,Light].png new file mode 100644 index 00000000..724a6e69 Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Alert,Light].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Default,Dark].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Default,Dark].png new file mode 100644 index 00000000..c4283069 Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Default,Dark].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Default,Light].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Default,Light].png new file mode 100644 index 00000000..7e13832f Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Default,Light].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Strikethrough,Dark].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Strikethrough,Dark].png new file mode 100644 index 00000000..dfdaa546 Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Strikethrough,Dark].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Strikethrough,Light].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Strikethrough,Light].png new file mode 100644 index 00000000..25650a12 Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_large[Strikethrough,Light].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Accent,Dark].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Accent,Dark].png new file mode 100644 index 00000000..a9273522 Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Accent,Dark].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Accent,Light].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Accent,Light].png new file mode 100644 index 00000000..a005ee3a Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Accent,Light].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Alert,Dark].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Alert,Dark].png new file mode 100644 index 00000000..0a236dba Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Alert,Dark].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Alert,Light].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Alert,Light].png new file mode 100644 index 00000000..087d62f9 Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Alert,Light].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Default,Dark].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Default,Dark].png new file mode 100644 index 00000000..dbfd6135 Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Default,Dark].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Default,Light].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Default,Light].png new file mode 100644 index 00000000..151cb706 Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Default,Light].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Strikethrough,Dark].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Strikethrough,Dark].png new file mode 100644 index 00000000..08aa1d30 Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Strikethrough,Dark].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Strikethrough,Light].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Strikethrough,Light].png new file mode 100644 index 00000000..91876805 Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_medium[Strikethrough,Light].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Accent,Dark].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Accent,Dark].png new file mode 100644 index 00000000..171f7981 Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Accent,Dark].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Accent,Light].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Accent,Light].png new file mode 100644 index 00000000..b2d3334d Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Accent,Light].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Alert,Dark].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Alert,Dark].png new file mode 100644 index 00000000..67840d61 Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Alert,Dark].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Alert,Light].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Alert,Light].png new file mode 100644 index 00000000..d80cfb4b Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Alert,Light].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Default,Dark].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Default,Dark].png new file mode 100644 index 00000000..33dca6bc Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Default,Dark].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Default,Light].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Default,Light].png new file mode 100644 index 00000000..70617774 Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Default,Light].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Strikethrough,Dark].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Strikethrough,Dark].png new file mode 100644 index 00000000..ab0dac61 Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Strikethrough,Dark].png differ diff --git a/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Strikethrough,Light].png b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Strikethrough,Light].png new file mode 100644 index 00000000..fed6e412 Binary files /dev/null and b/prices/src/test/snapshots/images/com.decathlon.vitamin.compose.prices_VitaminPricesPrimaryTest_small[Strikethrough,Light].png differ