Skip to content

Instantly share code, notes, and snippets.

@Raiden18
Last active July 25, 2022 13:41
Show Gist options
  • Save Raiden18/7e0a7d45db9b94dc80495cf25d3c4985 to your computer and use it in GitHub Desktop.
Save Raiden18/7e0a7d45db9b94dc80495cf25d3c4985 to your computer and use it in GitHub Desktop.
@Test
fun `Should show search button when internet connection is reappeared`() {
val testInternetConnectionEmitter = TestObservableEmitter(true)
val viewModel = ViewModelBuilder()
.withFilters(filters)
.withPriceNotifications(priceNotifications)
.withInternetConnectionStatusEmitter(testInternetConnectionEmitter)
.withIgnoringCallingStatesWithViewModelIsCreated()
.build()
Cases(viewModel)
.internetConnectionDisappeared(testInternetConnectionEmitter)
.userHidesSearch()
.internetConnectionAppeared(testInternetConnectionEmitter)
.forgetScreenStateCalling()
.userClicksOnRetryButton()
assertThat(screenState)
.showedSearchButton()
}
@Test
fun `Should search items after reappearing internet connection`() {
val testInternetConnectionEmitter = TestObservableEmitter(true)
val viewModel = ViewModelBuilder()
.withFilters(filters)
.withPriceNotifications(priceNotifications)
.withInternetConnectionStatusEmitter(testInternetConnectionEmitter)
.withIgnoringCallingStatesWithViewModelIsCreated()
.build()
Cases(viewModel)
.userSearchesFor("Apple")
.internetConnectionDisappeared(testInternetConnectionEmitter)
.userHidesSearchView()
.internetConnectionAppeared(testInternetConnectionEmitter)
.userClicksOnRetryButton()
.forgetScreenStateCalling()
.userSearchesFor("Apple")
assertThat(screenState)
.showedNotificationsForFilter(
filters = filters,
currentSelectedFilter = PriceNotificationsFilter.Active,
priceNotification = activePriceNotifications,
exactly = 1
)
.didNotShowUnknownErrorState()
.didNotShowLoadingState()
.didNotShowNoNotificationsAtAll()
.didNotShowNoInternetErrorState()
.didNotShowShowNotificationsForFilterState()
.didNotShowNoNotificationsForSearch()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment