-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(snackbars): add paparazzi tests (#131)
Co-authored-by: ManonPolle <46710837+ManonPolle@users.noreply.github.com>
- Loading branch information
1 parent
a2a5577
commit 41d8cf2
Showing
7 changed files
with
103 additions
and
0 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
66 changes: 66 additions & 0 deletions
66
...ars/src/test/kotlin/com/decathlon/vitamin/compose/snackbars/VitaminSnackbarPrimaryTest.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,66 @@ | ||
package com.decathlon.vitamin.compose.snackbars | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
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.unit.dp | ||
import app.cash.paparazzi.Paparazzi | ||
import com.decathlon.vitamin.compose.foundation.VitaminTheme | ||
import com.decathlon.vitamin.compose.snackbars.utils.SnackbarVariantsFactory | ||
import com.decathlon.vitamin.compose.snackbars.utils.Theme | ||
import com.decathlon.vitamin.compose.snackbars.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 VitaminSnackbarPrimaryTest( | ||
@TestParameter val variant: Variant | ||
) { | ||
@get:Rule | ||
val paparazzi = Paparazzi() | ||
|
||
@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) | ||
SnackbarVariantsFactory.Snackbar( | ||
variant = variant | ||
) | ||
SnackbarVariantsFactory.Snackbar( | ||
variant = variant, | ||
action = { | ||
Button( | ||
text = "Button", | ||
onClick = { /*Not used in this context*/ } | ||
) | ||
} | ||
) | ||
SnackbarVariantsFactory.Snackbar( | ||
variant = variant, | ||
action = { | ||
Button( | ||
text = "Button", | ||
onClick = { /*Not used in this context*/ } | ||
) | ||
}, | ||
actionOnNewLine = true | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
.../src/test/kotlin/com/decathlon/vitamin/compose/snackbars/utils/SnackbarVariantsFactory.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,27 @@ | ||
package com.decathlon.vitamin.compose.snackbars.utils | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import com.decathlon.vitamin.compose.snackbars.VitaminSnackbars | ||
import com.decathlon.vitamin.compose.snackbars.VitaminSnackbarsActions | ||
|
||
object SnackbarVariantsFactory { | ||
|
||
@Composable | ||
fun Snackbar( | ||
variant: Variant, | ||
modifier: Modifier = Modifier, | ||
text: String = "This is the description of the snackbar", | ||
actionOnNewLine: Boolean = false, | ||
action: @Composable (VitaminSnackbarsActions.() -> Unit)? = null | ||
) { | ||
when (variant) { | ||
Variant.Primary -> VitaminSnackbars.Primary( | ||
modifier = modifier, | ||
text = text, | ||
action = action, | ||
actionOnNewLine = actionOnNewLine | ||
) | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
snackbars/src/test/kotlin/com/decathlon/vitamin/compose/snackbars/utils/Theme.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,3 @@ | ||
package com.decathlon.vitamin.compose.snackbars.utils | ||
|
||
enum class Theme { Light, Dark } |
5 changes: 5 additions & 0 deletions
5
snackbars/src/test/kotlin/com/decathlon/vitamin/compose/snackbars/utils/Variant.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,5 @@ | ||
package com.decathlon.vitamin.compose.snackbars.utils | ||
|
||
enum class Variant { | ||
Primary | ||
} |
Binary file added
BIN
+28.6 KB
...n.vitamin.compose.snackbars_VitaminSnackbarPrimaryTest_medium[Primary,Dark].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29.3 KB
....vitamin.compose.snackbars_VitaminSnackbarPrimaryTest_medium[Primary,Light].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.