Skip to content

Instantly share code, notes, and snippets.

@rozkminiacz
Created March 1, 2020 09:30
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rozkminiacz/7025a5c89a7788b703d215a54bad23ea to your computer and use it in GitHub Desktop.
import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
import io.reactivex.Single
import io.reactivex.schedulers.TestScheduler
import org.junit.Test
class MainScreenPresenterTest {
private val fakeCurrencyList: List<CurrencyModel> = listOf(
CurrencyModel(
name = "Bitcoin",
symbol = "BTC",
priceUsd = "9877.96"
),
CurrencyModel(
name = "Etherum",
symbol = "ETH",
priceUsd = "271.57"
)
)
@Test
fun `GIVEN successful data fetch WHEN screen opens THEN display data`() {
val view: MainScreenContract.View = mockk(relaxed = true)
val fetchCurrencyUseCase: FetchCurrencyUseCase = mockk {
every { execute() } returns Single.just(fakeCurrencyList)
}
val presenter = MainScreenPresenter(
fetchCurrencyUseCase = fetchCurrencyUseCase,
schedulerProvider = TrampolineTestSchedulers()
)
presenter.attach(view)
verify {
view.displayData(fakeCurrencyList)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment