Last active
January 25, 2021 01:26
-
-
Save drawers/5bec0116dfb7bf79bb7e28396c9364f5 to your computer and use it in GitHub Desktop.
DDDTest.kt
This file contains 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
class TasksViewModel: ViewModel { | |
val taskItems: LiveData<List<TaskItem>> | |
val _tasksItems: MutableLiveData<List<TaskItem>> | |
fun loadTasks() { | |
val tasks = tasksRepository.getAllTasks() | |
_taskItems.value = tasks.map { it.toTaskItem() } | |
} | |
} | |
class TasksViewModelTest { | |
@Test | |
fun `completedTasksAreRed`() { | |
viewModel.loadTasks() | |
val firstTask = tasksItemsLiveData.currentItems().first() | |
firstTask.isComplete.shouldBeTrue() | |
firstTask.color.shouldEqual(R.color.red) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment