Skip to content

Commit

Permalink
chore(prices): add paparazzi tests (#132)
Browse files Browse the repository at this point in the history
Co-authored-by: ManonPolle <[email protected]>
  • Loading branch information
FDELAHA24 and ManonPolle committed Apr 20, 2023
1 parent 38bb2ff commit a2a5577
Show file tree
Hide file tree
Showing 29 changed files with 143 additions and 0 deletions.
2 changes: 2 additions & 0 deletions prices/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Original file line number Diff line number Diff line change
@@ -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()
)
}
}
}
}
}

}
Original file line number Diff line number Diff line change
@@ -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
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.decathlon.vitamin.compose.prices.utils

enum class Theme { Light, Dark }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.decathlon.vitamin.compose.prices.utils

enum class Variant {
Default, Accent, Alert, Strikethrough
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a2a5577

Please sign in to comment.