Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@Test
fun `ON start fetching data IT SHOULD show progress indicator`() {
val view: MainScreenContract.View = mockk(relaxed = true)
val fetchCurrencyUseCase: FetchCurrencyUseCase = mockk {
every { execute() } returns Single.never()
}
val presenter = MainScreenPresenter(
fetchCurrencyUseCase = fetchCurrencyUseCase,
schedulerProvider = TrampolineTestSchedulers()
)
presenter.attach(view)
verify {
view.toggleLoadingIndicator(true)
}
}
@Test
fun `ON fetching data complete IT SHOULD hide progress indicator`() {
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.toggleLoadingIndicator(false)
}
}
@Test
fun `ON fetching data error IT SHOULD hide progress indicator`() {
val view: MainScreenContract.View = mockk(relaxed = true)
val fetchCurrencyUseCase: FetchCurrencyUseCase = mockk {
every { execute() } returns Single.error(Throwable("error occurred"))
}
val presenter = MainScreenPresenter(
fetchCurrencyUseCase = fetchCurrencyUseCase,
schedulerProvider = TrampolineTestSchedulers()
)
presenter.attach(view)
verify {
view.toggleLoadingIndicator(false)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment