Skip to content

Commit

Permalink
Merge pull request #153 from wisemuji/feature/#149
Browse files Browse the repository at this point in the history
  • Loading branch information
wisemuji authored Jul 31, 2023
2 parents 78bb3bc + 60d3f4b commit dd4046d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ internal class DefaultContributorRepositoryTest : BehaviorSpec() {
)

init {
Given("기여자가 존재한다") {
Given("컨트리뷰터가 존재한다") {
val expected = contributors

When("기여자를 조회한다") {
When("컨트리뷰터를 조회한다") {
val contributors: List<Contributor> = repository.getContributors(
owner = "droidknights",
name = "app2023"
)
Then("기여자를 반환한다") {
Then("컨트리뷰터를 반환한다") {
contributors.size shouldBe 1
contributors.all {
it.name == expected[0].name
Expand Down
Empty file.
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"
)
)
}
}

0 comments on commit dd4046d

Please sign in to comment.