Skip to content

Commit

Permalink
Merge branch 'stream/episode_13' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaquimLey committed Sep 30, 2018
2 parents 035ce58 + 9d24633 commit bf59992
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ Since I'm always working on some side-projects, I decided to document the develo

- Ep.12: https://github.com/JoaquimLey/transport-eta/pull/49

- Ep.13: https://github.com/JoaquimLey/transport-eta/pull/64


## About the author
Hi, my name is **Joaquim Ley**, I'm a Software Engineer (Android).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ internal class FavoritesViewModelImpl(getFavoritesUseCase: GetFavoritesUseCase,
override fun onEtaRequestCanceled() {
compositeDisposable.add(cancelEtaRequestUseCase.execute(null)
.subscribe({
// TODO Handle eta request cancelled (push something to the UI boie)
// TODO Handle eta request cancelled (push something to the UI)
acceptingRequestsLiveData.postValue(true)
}, {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class FavoritesViewModelTest {
// Assemble
robot.stubGetFavoritesUseCaseSuccess()
// Act
// -> No action
// -> No action, this in reality whats being tested
// Assert
verify(mockGetFavoritesUseCase, atLeastOnce()).execute(anyOrNull())
}
Expand Down Expand Up @@ -255,6 +255,17 @@ class FavoritesViewModelTest {
assert(viewModel.isAcceptingRequests().value == true)
}

@Test
fun onEtaRequestedFailedTriggersAcceptingRequestsTrue() {
// Assemble
val transportView = TransportFactory.makeTransportView()
robot.stubRequestEtaUseCaseFailed(transportView)
// Act
viewModel.onEtaRequested(transportView)
// Assert
assert(viewModel.isAcceptingRequests().value == true)
}

inner class Robot {

// region Robot public API
Expand All @@ -263,6 +274,12 @@ class FavoritesViewModelTest {
return stubRequestEtaUseCase(transportView.code)
}

fun stubRequestEtaUseCaseFailed(transportView: TransportView = TransportFactory.makeTransportView(), errorMessage: String = DataFactory.randomString()): Throwable {
val throwable = Throwable(errorMessage)
stubRequestEtaUseCase(transportView.code, Observable.error(throwable))
return throwable
}

fun stubGetFavoritesUseCaseSuccess(flowable: List<Transport>? = null, count: Int = 3): List<Transport> {
val testData = flowable ?: TransportFactory.makeTransportList(count)
stubExecuteGetFavoritesUseCase(Flowable.just(testData))
Expand Down

0 comments on commit bf59992

Please sign in to comment.