-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
3 changed files
with
45 additions
and
3 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
Empty file.
42 changes: 42 additions & 0 deletions
42
...or/src/test/java/com/droidknights/app2023/feature/contributor/ContributorViewModelTest.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,42 @@ | ||
package com.droidknights.app2023.feature.contributor | ||
|
||
import app.cash.turbine.test | ||
import com.droidknights.app2023.core.domain.usecase.GetContributorsUseCase | ||
import com.droidknights.app2023.core.model.Contributor | ||
import com.droidknights.app2023.core.testing.rule.MainDispatcherRule | ||
import io.mockk.coEvery | ||
import io.mockk.mockk | ||
import kotlinx.coroutines.test.runTest | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import kotlin.test.assertIs | ||
|
||
internal class ContributorViewModelTest { | ||
@get:Rule | ||
val dispatcherRule = MainDispatcherRule() | ||
|
||
private val getContributorsUseCase: GetContributorsUseCase = mockk() | ||
private lateinit var viewModel: ContributorViewModel | ||
|
||
@Test | ||
fun `컨트리뷰터 데이터를 확인할 수 있다`() = runTest { | ||
// given | ||
coEvery { getContributorsUseCase() } returns fakeContributors | ||
viewModel = ContributorViewModel(getContributorsUseCase) | ||
|
||
// when & then | ||
viewModel.uiState.test { | ||
val actual: ContributorsUiState = awaitItem() | ||
assertIs<ContributorsUiState.Contributors>(actual) | ||
} | ||
} | ||
|
||
companion object { | ||
private val fakeContributors = listOf( | ||
Contributor( | ||
name = "test name", | ||
imageUrl = "test image url" | ||
) | ||
) | ||
} | ||
} |