@@ -71,33 +71,32 @@ class TasksViewModelTest {
71
71
}
72
72
73
73
@Test
74
- fun loadAllTasksFromRepository_loadingTogglesAndDataLoaded () =
75
- runTest {
76
- // Override eagerly executing Main dispatcher for just a single test
77
- Dispatchers .setMain(StandardTestDispatcher ())
74
+ fun loadAllTasksFromRepository_loadingTogglesAndDataLoaded () = runTest {
75
+ // Override eagerly executing Main dispatcher for just a single test
76
+ Dispatchers .setMain(StandardTestDispatcher ())
78
77
79
- // Given an initialized TasksViewModel with initialized tasks
80
- // When loading of Tasks is requested
81
- tasksViewModel.setFiltering(TasksFilterType .ALL_TASKS )
78
+ // Given an initialized TasksViewModel with initialized tasks
79
+ // When loading of Tasks is requested
80
+ tasksViewModel.setFiltering(TasksFilterType .ALL_TASKS )
82
81
83
- // Trigger loading of tasks
84
- tasksViewModel.loadTasks(true )
85
- // Observe the items to keep LiveData emitting
86
- tasksViewModel.items.observeForTesting {
82
+ // Trigger loading of tasks
83
+ tasksViewModel.loadTasks(true )
84
+ // Observe the items to keep LiveData emitting
85
+ tasksViewModel.items.observeForTesting {
87
86
88
- // Then progress indicator is shown
89
- assertThat(tasksViewModel.dataLoading.getOrAwaitValue()).isTrue()
87
+ // Then progress indicator is shown
88
+ assertThat(tasksViewModel.dataLoading.getOrAwaitValue()).isTrue()
90
89
91
- // Execute pending coroutines actions
92
- advanceUntilIdle()
90
+ // Execute pending coroutines actions
91
+ advanceUntilIdle()
93
92
94
- // Then progress indicator is hidden
95
- assertThat(tasksViewModel.dataLoading.getOrAwaitValue()).isFalse()
93
+ // Then progress indicator is hidden
94
+ assertThat(tasksViewModel.dataLoading.getOrAwaitValue()).isFalse()
96
95
97
- // And data correctly loaded
98
- assertThat(tasksViewModel.items.getOrAwaitValue()).hasSize(3 )
99
- }
96
+ // And data correctly loaded
97
+ assertThat(tasksViewModel.items.getOrAwaitValue()).hasSize(3 )
100
98
}
99
+ }
101
100
102
101
@Test
103
102
fun loadActiveTasksFromRepositoryAndLoadIntoView () = runTest {
0 commit comments