View HomePresenter.kt
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
searchTermUpdate | |
.debounce(DELAY_BETWEEN_SEARCH_TERM_REQUEST, TimeUnit.MILLISECONDS) | |
.switchMapSingle { searchTerm -> suggestionsRepository.getSearchTermSuggestions(searchTerm) } | |
.subscribe { suggestions -> view.showSearchSuggestions(suggestions) }) |
View HomePresenterTest.kt
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
@Test | |
fun onTextTyped_showSearchSuggestions() { | |
`when`(suggestionsRepository.getSearchTermSuggestions(ANY_SEARCH_TERM)).thenReturn(Single.just(ANY_SUGGESTIONS_LIST)) | |
val presenter = createSUT() | |
presenter.onNewSearch(ANY_SEARCH_TERM) | |
verify(view).showSearchSuggestions(ANY_SUGGESTIONS_LIST) | |
} |
View ComputationSchedulerTestRule.kt
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
class ComputationSchedulerTestRule : TestRule { | |
val computationScheduler: TestScheduler = TestScheduler() | |
override fun apply(statement: Statement?, p1: Description?): Statement { | |
return object : Statement() { | |
@Throws(Throwable::class) | |
override fun evaluate() { | |
RxJavaPlugins.setComputationSchedulerHandler { computationScheduler } |