Skip to content

Commit

Permalink
chore(checkboxes): add paparazzi tests (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
FDELAHA24 committed Jul 12, 2023
1 parent c0a1978 commit c64ddc7
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 1 deletion.
2 changes: 2 additions & 0 deletions checkboxes/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
Expand Up @@ -60,7 +60,7 @@ object VitaminCheckboxes {
val alpha = if (enabled) 1f else VtmnStatesDisabled
Spacer(modifier = Modifier.width(7.dp))
CompositionLocalProvider(LocalContentAlpha provides alpha) {
ProvideTextStyle(value = textStyle.copy(color = colors.contentColor)) {
ProvideTextStyle(value = textStyle.copy(color = colors.contentColor.copy(alpha = alpha))) {
endContent()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.decathlon.vitamin.compose.checkboxes.utils

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

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.unit.dp
import app.cash.paparazzi.Paparazzi
import com.decathlon.vitamin.compose.checkboxes.VitaminCheckboxes
import com.decathlon.vitamin.compose.foundation.VitaminTheme
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 VitaminCheckboxesPrimaryTest {
@get:Rule
val paparazzi = Paparazzi()

@Test
fun primary(@TestParameter theme: Theme) {
paparazzi.snapshot {
VitaminTheme(theme == Theme.Dark) {
Scaffold { padding ->
Column(
modifier = Modifier.padding(padding),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
Text(text = "Primary", style = VitaminTheme.typography.subtitle1)
Row(
horizontalArrangement = Arrangement.spacedBy(4.dp),
) {
VitaminCheckboxes.Primary(checked = true, onCheckedChange = {})
VitaminCheckboxes.Primary(
checked = true,
enabled = false,
onCheckedChange = {})
}
Row(
horizontalArrangement = Arrangement.spacedBy(4.dp),
) {
VitaminCheckboxes.Primary(checked = false, onCheckedChange = {})
VitaminCheckboxes.Primary(
checked = false,
enabled = false,
onCheckedChange = {})
}
Column(
verticalArrangement = Arrangement.spacedBy(4.dp),
) {
VitaminCheckboxes.Primary(checked = true, onCheckedChange = {}){
Text(text = "Enabled and checked")
}
VitaminCheckboxes.Primary(
checked = true,
enabled = false,
onCheckedChange = {}) {
Text(text = "Disabled and checked")
}
}
}
}
}
}

}

}
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 c64ddc7

Please sign in to comment.