mirror of
https://github.com/bitwarden/android.git
synced 2026-05-31 01:22:39 -05:00
Add updateToPendingOrLoading helper method (#390)
This commit is contained in:
@@ -23,4 +23,22 @@ class DataStateExtensionsTest {
|
||||
awaitComplete()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `updateToPendingOrLoading should change the DataState to Pending when data is present`() {
|
||||
val mutableStateFlow = MutableStateFlow<DataState<Unit>>(DataState.Loaded(Unit))
|
||||
|
||||
mutableStateFlow.updateToPendingOrLoading()
|
||||
|
||||
assertEquals(DataState.Pending(Unit), mutableStateFlow.value)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `updateToPendingOrLoading should change the DataState to Loading when data is absent`() {
|
||||
val mutableStateFlow = MutableStateFlow<DataState<Unit>>(DataState.Error(Throwable("Fail")))
|
||||
|
||||
mutableStateFlow.updateToPendingOrLoading()
|
||||
|
||||
assertEquals(DataState.Loading, mutableStateFlow.value)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user