-
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 new targets to core, -compose and -flow modules
Compose module now supports macos and ios targets, while core and flow modules support additionally linux
- Loading branch information
Showing
18 changed files
with
129 additions
and
87 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
kotlin.code.style=official | ||
|
||
android.useAndroidX=true | ||
|
||
kotlin.native.cacheKind=none | ||
|
||
org.jetbrains.compose.experimental.macos.enabled=true | ||
org.jetbrains.compose.experimental.uikit.enabled=true |
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
Binary file not shown.
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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
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
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
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
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
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
38 changes: 16 additions & 22 deletions
38
.../remotedata/compose/RemoteDataViewTest.kt → .../remotedata/compose/RemoteDataViewTest.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 |
---|---|---|
@@ -1,89 +1,83 @@ | ||
package remotedata.compose | ||
|
||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.runtime.Composable | ||
import io.mockk.mockk | ||
import io.mockk.verify | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.testTag | ||
import remotedata.RemoteData | ||
import remotedata.RemoteData.Companion.failure | ||
import remotedata.RemoteData.Companion.success | ||
import kotlin.test.fail | ||
|
||
interface ComposeTestContext { | ||
fun setContent(composable: @Composable () -> Unit) | ||
fun assertExistsSingle(testTag: String) | ||
} | ||
|
||
fun ComposeTestContext.testNotAsked() { | ||
val rd = RemoteData.NotAsked | ||
val notAsked: () -> Unit = mockk(relaxed = true) | ||
val tag = "not asked" | ||
|
||
setContent { | ||
RemoteDataView( | ||
remoteData = rd, | ||
notAsked = { notAsked() }, | ||
notAsked = { Box(modifier = Modifier.testTag(tag)) }, | ||
loading = { fail() }, | ||
failure = { fail() }, | ||
success = { fail() }, | ||
) | ||
} | ||
|
||
verify(exactly = 1) { | ||
notAsked() | ||
} | ||
assertExistsSingle(testTag = tag) | ||
} | ||
|
||
fun ComposeTestContext.testLoading() { | ||
val rd = RemoteData.Loading | ||
val loading: () -> Unit = mockk(relaxed = true) | ||
val tag = "loading" | ||
|
||
setContent { | ||
RemoteDataView( | ||
remoteData = rd, | ||
notAsked = { fail() }, | ||
loading = { loading() }, | ||
loading = { Box(modifier = Modifier.testTag(tag)) }, | ||
failure = { fail() }, | ||
success = { fail() }, | ||
) | ||
} | ||
|
||
verify(exactly = 1) { | ||
loading() | ||
} | ||
assertExistsSingle(testTag = tag) | ||
} | ||
|
||
fun ComposeTestContext.testFailure() { | ||
val rd = "test error".failure() | ||
val failure: () -> Unit = mockk(relaxed = true) | ||
val tag = "failure" | ||
|
||
setContent { | ||
RemoteDataView( | ||
remoteData = rd, | ||
notAsked = { fail() }, | ||
loading = { fail() }, | ||
failure = { failure() }, | ||
failure = { Box(modifier = Modifier.testTag(tag = tag)) }, | ||
success = { fail() }, | ||
) | ||
} | ||
|
||
verify(exactly = 1) { | ||
failure() | ||
} | ||
assertExistsSingle(testTag = tag) | ||
} | ||
|
||
fun ComposeTestContext.testSuccess() { | ||
val rd = "test data".success() | ||
val success: () -> Unit = mockk(relaxed = true) | ||
val tag = "success" | ||
|
||
setContent { | ||
RemoteDataView( | ||
remoteData = rd, | ||
notAsked = { fail() }, | ||
loading = { fail() }, | ||
failure = { fail() }, | ||
success = { success() }, | ||
success = { Box(modifier = Modifier.testTag(tag = tag)) }, | ||
) | ||
} | ||
|
||
verify(exactly = 1) { | ||
success() | ||
} | ||
assertExistsSingle(testTag = tag) | ||
} |
Oops, something went wrong.