Skip to content

Commit 31537d3

Browse files
author
deepsandhya
committed
Unit test complete
1 parent d6b74b5 commit 31537d3

File tree

16 files changed

+394
-27
lines changed

16 files changed

+394
-27
lines changed

README.md

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,4 @@
3030
This is a Kotlin Multiplatform project targeting Android, iOS, Web, Desktop.
3131

3232

33-
* `/composeApp` is for code that will be shared across your Compose Multiplatform applications.
34-
It contains several subfolders:
35-
- `commonMain` is for code that’s common for all targets.
36-
- Other folders are for Kotlin code that will be compiled for only the platform indicated in the folder name.
37-
For example, if you want to use Apple’s CoreCrypto for the iOS part of your Kotlin app,
38-
`iosMain` would be the right folder for such calls.
39-
40-
* `/iosApp` contains iOS applications. Even if you’re sharing your UI with Compose Multiplatform,
41-
you need this entry point for your iOS app. This is also where you should add SwiftUI code for your project.
42-
43-
44-
Learn more about [Kotlin Multiplatform](https://www.jetbrains.com/help/kotlin-multiplatform-dev/get-started.html),
45-
[Compose Multiplatform](https://github.com/JetBrains/compose-multiplatform/#compose-multiplatform),
46-
[Kotlin/Wasm](https://kotl.in/wasm/)
47-
48-
We would appreciate your feedback on Compose/Web and Kotlin/Wasm in the public Slack channel [#compose-web](https://slack-chats.kotlinlang.org/c/compose-web).
49-
If you face any issues, please report them on [YouTrack](https://youtrack.jetbrains.com/newIssue?project=CMP).
50-
51-
You can open the web application by running the `:composeApp:wasmJsBrowserDevelopmentRun` Gradle task.
33+
Run the command from Makefile to run the respective Platform

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ ktor-client-serialization-json = { group = "io.ktor", name = "ktor-serialization
6969

7070
logging-napier = { module = "io.github.aakira:napier", version = "2.7.1" }
7171

72+
test-turbine = { module="app.cash.turbine:turbine", version = "1.2.1" }
73+
7274
[plugins]
7375
android-application = { id = "com.android.application", version.ref = "agp" }
7476
android-library = { id = "com.android.library", version.ref = "agp" }

sharedCode/build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@file:OptIn(ExperimentalWasmDsl::class)
22
import org.gradle.kotlin.dsl.getByType
3+
import org.gradle.kotlin.dsl.invoke
34
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
45
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
56
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
@@ -13,6 +14,7 @@ plugins {
1314
alias(libs.plugins.compose.compiler)
1415
alias(libs.plugins.kotlin.serialization)
1516
alias(libs.plugins.ksp)
17+
alias(libs.plugins.mokkery)
1618
}
1719

1820
kotlin {
@@ -89,6 +91,8 @@ kotlin {
8991

9092
commonTest.dependencies {
9193
implementation(libs.kotlin.test)
94+
implementation(libs.kotlinx.coroutines.test)
95+
implementation(libs.test.turbine)
9296
}
9397

9498
desktopMain.dependencies {
@@ -124,6 +128,10 @@ ksp {
124128
arg("me.tatarka.inject.generateCompanionExtensions", "true")
125129
}
126130

131+
mokkery {
132+
ignoreFinalMembers.set(true)
133+
}
134+
127135
fun Project.addKspDependencyForAllTargets(dependencyNotation: Any) = addKspDependencyForAllTargets("", dependencyNotation)
128136
fun Project.addKspTestDependencyForAllTargets(dependencyNotation: Any) = addKspDependencyForAllTargets("Test", dependencyNotation)
129137

sharedCode/src/commonMain/kotlin/dev/reprator/github/features/userDetail/presentation/ui/UserDetailScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private fun UserDetailScreen(
126126
onAction: OnAction,
127127
modifier: Modifier = Modifier
128128
) {
129-
Column(modifier = modifier.fillMaxSize()) {
129+
Column(modifier = modifier.padding(12.dp).fillMaxSize()) {
130130
UserToolbar(
131131
state.userInfo.userName,
132132
state.userInfo.profilePic,

sharedCode/src/commonMain/kotlin/dev/reprator/github/features/userList/presentation/UserListScreenReducer.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import io.github.aakira.napier.Napier
55
import me.tatarka.inject.annotations.Inject
66

77
@Inject
8-
class UserListScreenReducer :
9-
Reducer<UserListState, UserListAction, UserListEffect> {
8+
class UserListScreenReducer : Reducer<UserListState, UserListAction, UserListEffect> {
109

1110
override fun reduce(
1211
previousState: UserListState,
@@ -74,7 +73,9 @@ class UserListScreenReducer :
7473

7574
//Search query is empty, so fetch user list
7675
return previousState.copy(
77-
userLoading = true
76+
userLoading = true,
77+
errorMessage = "",
78+
isError = false,
7879
) to null
7980
}
8081
}

sharedCode/src/commonMain/kotlin/dev/reprator/github/features/userList/presentation/UserListViewModel.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package dev.reprator.github.features.userList.presentation
22

3-
import androidx.lifecycle.Lifecycle
43
import androidx.lifecycle.SavedStateHandle
54
import androidx.lifecycle.ViewModel
6-
import androidx.lifecycle.flowWithLifecycle
75
import androidx.lifecycle.viewModelScope
86
import dev.reprator.github.util.AppCoroutineDispatchers
97
import dev.reprator.github.util.base.mvi.MVI
@@ -22,7 +20,7 @@ import kotlinx.coroutines.launch
2220
import me.tatarka.inject.annotations.Assisted
2321
import me.tatarka.inject.annotations.Inject
2422

25-
private const val SEARCH_QUERY_KEY = "searchQuery"
23+
const val SEARCH_QUERY_KEY = "searchQuery"
2624
private const val MINIMUM_SEARCH_DEBOUNCE = 100L
2725
private const val MINIMUM_SEARCH_LENGTH = 3
2826

sharedCode/src/commonMain/kotlin/dev/reprator/github/features/userList/presentation/ui/UserListScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private fun UserListScreen(
145145
onSearchQueryChanged: (String) -> Unit = {},
146146
lazyListState: LazyListState = rememberLazyListState()
147147
) {
148-
Column(modifier = modifier) {
148+
Column(modifier = modifier.padding(12.dp)) {
149149

150150
SearchTextField(currentSearchQuery, onSearchQueryChanged, { query ->
151151
onAction(UserListAction.SearchUsers(query, state.userList.isEmpty()))

0 commit comments

Comments
 (0)