-
-
Save rozkminiacz/7025a5c89a7788b703d215a54bad23ea to your computer and use it in GitHub Desktop.
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
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