Skip to content

Commit

Permalink
chore(switches): add paparazzi tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FDELAHA24 authored and corentin-stamper committed Apr 6, 2023
1 parent f80edf9 commit 8b0eae1
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 0 deletions.
2 changes: 2 additions & 0 deletions switches/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,71 @@
package com.decathlon.vitamin.compose.switches

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.fillMaxWidth
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.switches.utils.Theme
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 VitaminSwitchesPrimaryTest {
@get:Rule
val paparazzi = Paparazzi()

@Suppress("LongMethod")
@Test
fun medium(@TestParameter theme: Theme) {
paparazzi.snapshot {
VitaminTheme(theme == Theme.Dark) {
Scaffold { padding ->
Column(
modifier = Modifier
.padding(padding)
.fillMaxWidth()
.background(VitaminTheme.colors.vtmnBackgroundPrimary),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
Text(text = "Primary", style = VitaminTheme.typography.subtitle1)
Row(
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
VitaminSwitches.Primary(
checked = true,
enabled = true
)
VitaminSwitches.Primary(
checked = false,
enabled = true
)
}
Row(
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
VitaminSwitches.Primary(
checked = true,
enabled = false
)
VitaminSwitches.Primary(
checked = false,
enabled = false
)
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.decathlon.vitamin.compose.switches.utils

enum class Theme { Light, Dark }
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 8b0eae1

Please sign in to comment.