-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5b3775
commit 3f9ea4b
Showing
13 changed files
with
183 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
132 changes: 132 additions & 0 deletions
132
modals/src/test/kotlin/com/decathlon/vitamin/compose/modals/VitaminModalsPrimaryTest.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,132 @@ | ||
package com.decathlon.vitamin.compose.modals | ||
|
||
import androidx.compose.material.Text | ||
import app.cash.paparazzi.Paparazzi | ||
import com.decathlon.vitamin.compose.foundation.VitaminTheme | ||
import com.decathlon.vitamin.compose.modals.utils.DataFactory | ||
import com.decathlon.vitamin.compose.modals.utils.Theme | ||
import com.decathlon.vitamin.compose.modals.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 VitaminModalsPrimaryTest( | ||
@TestParameter val variant: Variant | ||
) { | ||
|
||
@get:Rule | ||
val paparazzi = Paparazzi() | ||
|
||
@Test | ||
fun primary( | ||
@TestParameter theme: Theme | ||
) { | ||
paparazzi.snapshot { | ||
VitaminTheme(theme == Theme.Dark) { | ||
VitaminModals.Primary( | ||
onDismissRequest = {}, | ||
iconRes = R.drawable.ic_vtmn_map_pin_line, | ||
title = DataFactory.title, | ||
content = { | ||
Text( | ||
text = DataFactory.message | ||
) | ||
}, | ||
positiveButton = { | ||
VitaminModalButtons.Primary( | ||
text = "Button", | ||
onClick = {} | ||
) | ||
}, | ||
negativeButton = { | ||
VitaminModalButtons.Primary( | ||
text = "Button", | ||
onClick = {} | ||
) | ||
} | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun primaryLongMessage( | ||
@TestParameter theme: Theme | ||
) { | ||
paparazzi.snapshot { | ||
VitaminTheme(theme == Theme.Dark) { | ||
VitaminModals.Primary( | ||
onDismissRequest = {}, | ||
iconRes = R.drawable.ic_vtmn_map_pin_line, | ||
title = DataFactory.title, | ||
content = { | ||
Text( | ||
text = DataFactory.longAnnotatedMessage | ||
) | ||
}, | ||
positiveButton = { | ||
VitaminModalButtons.Primary( | ||
text = "Button", | ||
onClick = {} | ||
) | ||
}, | ||
negativeButton = { | ||
VitaminModalButtons.Primary( | ||
text = "Button", | ||
onClick = {} | ||
) | ||
} | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun primaryWithoutButtons( | ||
@TestParameter theme: Theme | ||
) { | ||
paparazzi.snapshot { | ||
VitaminTheme(theme == Theme.Dark) { | ||
VitaminModals.Primary( | ||
onDismissRequest = {}, | ||
iconRes = R.drawable.ic_vtmn_map_pin_line, | ||
title = DataFactory.title, | ||
content = { | ||
Text( | ||
text = DataFactory.message | ||
) | ||
} | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun primaryWithNeutralButton( | ||
@TestParameter theme: Theme | ||
) { | ||
paparazzi.snapshot { | ||
VitaminTheme(theme == Theme.Dark) { | ||
VitaminModals.Primary( | ||
onDismissRequest = {}, | ||
iconRes = R.drawable.ic_vtmn_map_pin_line, | ||
title = DataFactory.title, | ||
content = { | ||
Text( | ||
text = DataFactory.message | ||
) | ||
}, | ||
neutralButton = { | ||
VitaminModalButtons.Primary( | ||
text = "Button", | ||
onClick = {} | ||
) | ||
} | ||
) | ||
} | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
modals/src/test/kotlin/com/decathlon/vitamin/compose/modals/utils/DataFactory.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,41 @@ | ||
package com.decathlon.vitamin.compose.modals.utils | ||
|
||
import androidx.compose.ui.text.AnnotatedString | ||
import androidx.compose.ui.text.SpanStyle | ||
import androidx.compose.ui.text.buildAnnotatedString | ||
import androidx.compose.ui.text.font.FontStyle | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.withStyle | ||
|
||
class DataFactory { | ||
|
||
companion object { | ||
internal val title: String = "Subtitle" | ||
internal val message: String = "Lorem ipsum dolor sit amet, consectetur adipiscing " + | ||
"elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut " + | ||
"enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip " + | ||
"ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate " + | ||
"velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat " + | ||
"cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id " + | ||
"est laborum." | ||
internal val longAnnotatedMessage: AnnotatedString = buildAnnotatedString { | ||
append("$message\n\n") | ||
withStyle( | ||
style = SpanStyle(fontStyle = FontStyle.Italic) | ||
) { | ||
append("$message\n\n") | ||
} | ||
withStyle( | ||
style = SpanStyle(fontWeight = FontWeight.Bold) | ||
) { | ||
append("$message\n\n") | ||
} | ||
append("$message\n\n") | ||
withStyle( | ||
style = SpanStyle(fontStyle = FontStyle.Italic) | ||
) { | ||
append(message) | ||
} | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
modals/src/test/kotlin/com/decathlon/vitamin/compose/modals/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.modals.utils | ||
|
||
enum class Theme { Light, Dark } |
5 changes: 5 additions & 0 deletions
5
modals/src/test/kotlin/com/decathlon/vitamin/compose/modals/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.modals.utils | ||
|
||
enum class Variant { | ||
Primary | ||
} |
Binary file added
BIN
+132 KB
...in.compose.modals_VitaminModalsPrimaryTest_primaryLongMessage[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
+130 KB
...n.compose.modals_VitaminModalsPrimaryTest_primaryLongMessage[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.
Binary file added
BIN
+65.1 KB
...pose.modals_VitaminModalsPrimaryTest_primaryWithNeutralButton[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
+64.9 KB
...ose.modals_VitaminModalsPrimaryTest_primaryWithNeutralButton[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.
Binary file added
BIN
+63.1 KB
...compose.modals_VitaminModalsPrimaryTest_primaryWithoutButtons[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
+63 KB
...ompose.modals_VitaminModalsPrimaryTest_primaryWithoutButtons[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.
Binary file added
BIN
+66 KB
...thlon.vitamin.compose.modals_VitaminModalsPrimaryTest_primary[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
+65.8 KB
...hlon.vitamin.compose.modals_VitaminModalsPrimaryTest_primary[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.