Lucca Beurmann
12/25/2021, 6:37 PMLucca Beurmann
12/25/2021, 6:38 PMLucca Beurmann
12/25/2021, 6:42 PM@Test
fun `Should show error toast when get more photos fails`() = runBlockingTest {
coEvery {
getAuthorPhotoUseCase(
any(),
any()
)
} returns flow<Source<List<AuthorPhotos>>> {
emit(
Source.Error(
NetworkError(
"",
500
)
)
)
}
viewModel.events.test {
viewModel.getMoreAuthorPhotos()
coVerify(exactly = 1) { getAuthorPhotoUseCase(any(), any()) }
confirmVerified(getAuthorPhotoUseCase)
val emission = awaitItem()
assertTrue(emission is AuthorDetailsEvents.ShowErrorToast)
cancelAndIgnoreRemainingEvents()
}
}
Is this correct or just a workaround?gildor
12/27/2021, 4:24 AM