Skip to content

Instantly share code, notes, and snippets.

@mcatta
Last active October 25, 2022 20:26
Show Gist options
  • Save mcatta/1e6aff9110c05089d1475aecf674e917 to your computer and use it in GitHub Desktop.
Save mcatta/1e6aff9110c05089d1475aecf674e917 to your computer and use it in GitHub Desktop.
@Test
fun `Test confirm upon a failure`() = coroutineTestRule.scope.runTest {
// Given
coEvery { githubRepository.repositoryByOwner(any()) } returns Either.Left(AppError.Network)
// When / Then
stateMachine.state.test {
stateMachine.dispatch(GithubAction.TypeOwner("mcatta"))
stateMachine.dispatch(GithubAction.Confirm)
assertIs<GithubState.ContentState>(awaitItem()) // Initial State
assertIs<GithubState.ContentState>(awaitItem()) // State after typing
assertIs<GithubState.Load>(awaitItem()) // Confirm Action
assertIs<GithubState.Error>(awaitItem()) // Error upon API failure
coVerify { githubRepository.repositoryByOwner(eq("mcatta")) }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment