File tree Expand file tree Collapse file tree
android/app/src/test/java/com/clhs/score/viewmodel Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import kotlinx.coroutines.test.setMain
1818import org.junit.After
1919import org.junit.Assert.assertEquals
2020import org.junit.Assert.assertFalse
21+ import org.junit.Assert.assertTrue
2122import org.junit.Before
2223import org.junit.Test
2324
@@ -74,6 +75,21 @@ class ScheduleViewModelTest {
7475 assertEquals(" 202" , viewModel.uiState.value.selectedClassValue)
7576 }
7677
78+ @Test
79+ fun loadYearsErrorUpdatesState () = runTest(dispatcher) {
80+ val repository = ControllableScheduleRepository ()
81+ val viewModel = ScheduleViewModel (repository)
82+ runCurrent()
83+
84+ repository.yearsDeferred.completeExceptionally(RuntimeException (" Network error" ))
85+ runCurrent()
86+
87+ val state = viewModel.uiState.value
88+ assertFalse(state.isLoading)
89+ assertTrue(state.isError)
90+ assertEquals(" Network error" , state.errorMessage)
91+ }
92+
7793 @Test
7894 fun savingWidgetPreferencesLogsAnonymousAnalytics () = runTest(dispatcher) {
7995 val repository = ControllableScheduleRepository ()
You can’t perform that action at this time.
0 commit comments