This file contains hidden or 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
| spec { | |
| // ContentState | |
| inState<GithubState.ContentState> { | |
| on { action: GithubAction.TypeOwner, state: State<GithubState.ContentState> -> | |
| state.mutate { copy(owner = action.input) } | |
| } | |
| on { _: GithubAction.Confirm, state: State<GithubState.ContentState> -> | |
| val owner = state.snapshot.owner | |
| if (owner.isNotBlank()) { |
This file contains hidden or 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
| @ViewModelScoped | |
| class GithubStateMachine @Inject constructor( | |
| private val githubRepository: GithubRepository | |
| ) : FlowReduxStateMachine<GithubState, GithubAction>( | |
| initialState = GithubState.ContentState(owner = "", repositories = emptyList()) | |
| ) { | |
| init { | |
| spec { | |
| // spec | |
| } |
This file contains hidden or 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
| sealed interface GithubState { | |
| data class Load(val owner: String) : GithubState | |
| data class Error(val e: Throwable, val owner: String) : GithubState | |
| data class ContentState( | |
| val repositories: List<Repository> = emptyList(), | |
| val owner: String = "", | |
| ) : GithubState | |
| } | |
| sealed interface GithubAction { |
This file contains hidden or 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
| Column { | |
| Row { | |
| TextField( | |
| placeholder = { Text(text = "Owner") }, | |
| value = contentState.owner, onValueChange = { /* On type */ } | |
| ) | |
| Button( | |
| content = { Text(text = "OK") }, | |
| onClick = { /* Confirm */ } | |
| ) |
This file contains hidden or 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
| interface GithubRepository { | |
| suspend fun repositoryByOwner(owner: String): Either<AppError, List<Repository>> | |
| } |
This file contains hidden or 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
| @HiltAndroidTest | |
| internal class RepositoriesListingTest: BaseAndroidComposeTest() { | |
| override fun provideTestInstance() = this | |
| @Test | |
| fun testConfirmButtonBehaviour() { | |
| welcomeRobotScreen { | |
| isConfirmEnabled(false) | |
| typeUsername("mcatta") |
This file contains hidden or 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
| internal class WelcomeRobotScreen( | |
| private val baseAndroidComposeTest: BaseAndroidComposeTest | |
| ) : BaseRobotScreen( | |
| baseAndroidComposeTest.composeTestRule | |
| ) { | |
| private val usernameField by lazy { composeTestRule.onNode(hasText(getString(R.string.welcome_username_hint))) } | |
| private val confirmButton by lazy { composeTestRule.onNode(hasText(getString(R.string.welcome_confirm_button))) } |
This file contains hidden or 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
| // Search by contentDescription | |
| composeTestRule. | |
| onNodeWithContentDescription(label = "My fancy button").assertExists() | |
| // Search by a text (for example a button label) | |
| composeTestRule.onNode(hasText("My text label")).assertExists() | |
| // Search by testTag | |
| composeTestRule.onNode(hasTestTag("test_tag")).assertExists() |
This file contains hidden or 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
| package com.marand.domain.user.interactor | |
| import com.marand.domain.MainCoroutineRule | |
| import com.marand.domain.UseCase | |
| import com.marand.domain.factory.user.UsersFactory | |
| import com.marand.domain.user.entity.UserEntity | |
| import com.marand.domain.user.repository.UserRepository | |
| import io.mockk.coEvery | |
| import io.mockk.coVerify | |
| import io.mockk.mockk |