Skip to content

Commit

Permalink
[#22] Rebase fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
blyscuit committed Dec 26, 2022
1 parent edf4312 commit 5878ecb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protocol GetCurrentDateUseCaseKMM: GetCurrentDateUseCase {

func invoke() -> Kotlinx_coroutines_coreFlow
func invokeNative() -> (
@escaping (DateComponent, KotlinUnit) -> KotlinUnit,
@escaping (KotlinLong, KotlinUnit) -> KotlinUnit,
@escaping (Error?, KotlinUnit) -> KotlinUnit
) -> () -> KotlinUnit
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ final class SurveySelectionViewDataSourceSpec: QuickSpec {

describe("its fetch") {

let dateComponent = DateComponent(timeInterval: 1)
let user = User(name: "name", avatarUrl: "avatarUrl")

beforeEach {
getCurrentDateUseCase.invokeReturnValue = AnyFlow(result: dateComponent)
getCurrentDateUseCase.invokeReturnValue = AnyFlow(result: KotlinLong(1))
getProfileUseCase.invokeReturnValue = AnyFlow(result: user)
delayFetch()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package co.nimblehq.blisskmmic.presentation.modules.surveyselection

import co.nimblehq.blisskmmic.MR
import co.nimblehq.blisskmmic.domain.model.DateComponent
import co.nimblehq.blisskmmic.domain.model.User
import co.nimblehq.blisskmmic.domain.platform.datetime.DateFormat
import co.nimblehq.blisskmmic.domain.platform.datetime.DateTimeFormatter
Expand Down Expand Up @@ -61,8 +60,8 @@ class SurveySelectionViewModel(
}
}

private fun handleDateSuccess(dateComponent: DateComponent): String {
return dateTimeFormatter.getFormattedString(dateComponent.timeInterval, DateFormat.DayOfWeekMonthDay)
private fun handleDateSuccess(timeInterval: Long): String {
return dateTimeFormatter.getFormattedString(timeInterval, DateFormat.DayOfWeekMonthDay)
}

private fun updateHeaderState(user: User?, dateText: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package co.nimblehq.blisskmmic.presentation.modules.surveyselection

import app.cash.turbine.test
import co.nimblehq.blisskmmic.MR
import co.nimblehq.blisskmmic.domain.model.DateComponent
import co.nimblehq.blisskmmic.domain.model.User
import co.nimblehq.blisskmmic.domain.platform.datetime.DateTimeFormatter
import co.nimblehq.blisskmmic.domain.usecase.GetCurrentDateUseCase
Expand Down Expand Up @@ -36,9 +35,8 @@ class SurveySelectionViewModelTest : TestsWithMocks() {
lateinit var dateTimeFormatter: DateTimeFormatter
@Fake
lateinit var user: User
@Fake
lateinit var dateComponent: DateComponent

private var timeInterval = 1L
private val dateResult = "dateResult"
private val mainThreadSurrogate = newSingleThreadContext("UI thread")

Expand Down Expand Up @@ -71,7 +69,7 @@ class SurveySelectionViewModelTest : TestsWithMocks() {
fun `When calling fetch with success date and success user- it changes viewState with correct item`() = runTest {
mocker.every {
getCurrentDateUseCase()
} returns delayFlowOf(dateComponent)
} returns delayFlowOf(timeInterval)
mocker.every {
getProfileUseCase()
} returns flowOf(user)
Expand Down Expand Up @@ -119,7 +117,8 @@ class SurveySelectionViewModelTest : TestsWithMocks() {
fun `When calling fetch with success date and fail user- it changes viewState with correct item`() = runTest {
mocker.every {
getCurrentDateUseCase()
} returns flowOf(dateComponent)

} returns flowOf(timeInterval)
mocker.every {
getProfileUseCase()
} returns delayFlowOf("")
Expand Down

0 comments on commit 5878ecb

Please sign in to comment.