-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add some paparazzi tests for SquareToolCards
- Loading branch information
Showing
7 changed files
with
126 additions
and
1 deletion.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ru.godtools.ui.tools_SquareToolCardPaparazziTest_SquareToolCard() - Default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...odtools.ui.tools_SquareToolCardPaparazziTest_SquareToolCard() - Downloading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...i.tools_SquareToolCardPaparazziTest_SquareToolCard() - Show Second Language.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
113 changes: 113 additions & 0 deletions
113
app/src/testDebug/kotlin/org/cru/godtools/ui/tools/SquareToolCardPaparazziTest.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,113 @@ | ||
package org.cru.godtools.ui.tools | ||
|
||
import android.graphics.drawable.Drawable | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import app.cash.paparazzi.Paparazzi | ||
import coil.Coil | ||
import coil.ImageLoader | ||
import coil.annotation.ExperimentalCoilApi | ||
import coil.test.FakeImageLoaderEngine | ||
import io.mockk.mockk | ||
import java.util.Locale | ||
import kotlin.test.AfterTest | ||
import kotlin.test.BeforeTest | ||
import kotlin.test.Test | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.ExperimentalCoroutinesApi | ||
import kotlinx.coroutines.test.UnconfinedTestDispatcher | ||
import kotlinx.coroutines.test.resetMain | ||
import kotlinx.coroutines.test.setMain | ||
import org.cru.godtools.base.ui.theme.GodToolsTheme | ||
import org.cru.godtools.downloadmanager.DownloadProgress | ||
import org.cru.godtools.model.Language | ||
import org.cru.godtools.model.Tool | ||
import org.cru.godtools.model.randomTool | ||
import org.cru.godtools.model.randomTranslation | ||
import org.junit.Rule | ||
|
||
class SquareToolCardPaparazziTest { | ||
@get:Rule | ||
val paparazzi = Paparazzi() | ||
|
||
private val toolState = ToolCard.State( | ||
tool = randomTool( | ||
name = "Tool Title", | ||
category = Tool.CATEGORY_GOSPEL, | ||
), | ||
banner = mockk(), | ||
secondLanguage = Language(Locale.FRENCH), | ||
secondTranslation = randomTranslation() | ||
) | ||
|
||
@BeforeTest | ||
@OptIn(ExperimentalCoilApi::class, ExperimentalCoroutinesApi::class) | ||
fun setup() { | ||
Dispatchers.setMain(UnconfinedTestDispatcher()) | ||
val banner = Drawable.createFromStream(javaClass.getResourceAsStream("banner.jpg"), "banner.jpg")!! | ||
Coil.setImageLoader( | ||
ImageLoader.Builder(paparazzi.context) | ||
.components { | ||
add( | ||
FakeImageLoaderEngine.Builder() | ||
.intercept(toolState.banner!!, banner) | ||
.build() | ||
) | ||
} | ||
.build() | ||
) | ||
} | ||
|
||
@AfterTest | ||
@OptIn(ExperimentalCoroutinesApi::class) | ||
fun cleanup() { | ||
Coil.reset() | ||
Dispatchers.resetMain() | ||
} | ||
|
||
@Test | ||
fun `SquareToolCard() - Default`() { | ||
paparazzi.snapshot { | ||
GodToolsTheme(disableDagger = true) { | ||
Box { | ||
SquareToolCard( | ||
state = toolState, | ||
modifier = Modifier.align(Alignment.Center), | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun `SquareToolCard() - Downloading`() { | ||
paparazzi.snapshot { | ||
GodToolsTheme(disableDagger = true) { | ||
Box { | ||
SquareToolCard( | ||
state = toolState.copy( | ||
downloadProgress = DownloadProgress(2, 5) | ||
), | ||
modifier = Modifier.align(Alignment.Center), | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun `SquareToolCard() - Show Second Language`() { | ||
paparazzi.snapshot { | ||
GodToolsTheme(disableDagger = true) { | ||
Box { | ||
SquareToolCard( | ||
state = toolState, | ||
showSecondLanguage = true, | ||
modifier = Modifier.align(Alignment.Center), | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
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