|
|
|
@ -56,7 +56,7 @@ class NiaAppStateTest {
|
|
|
|
|
// Create the test dependencies.
|
|
|
|
|
private val networkMonitor = TestNetworkMonitor()
|
|
|
|
|
|
|
|
|
|
private val errorMonitor = TestErrorMonitor()
|
|
|
|
|
private val errorMonitor = TestErrorMonitor(networkMonitor)
|
|
|
|
|
|
|
|
|
|
private val timeZoneMonitor = TestTimeZoneMonitor()
|
|
|
|
|
|
|
|
|
@ -122,7 +122,7 @@ class NiaAppStateTest {
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
backgroundScope.launch { state.isOffline.collect() }
|
|
|
|
|
backgroundScope.launch { state.isOfflineState.collect() }
|
|
|
|
|
networkMonitor.setConnected(false)
|
|
|
|
|
assertEquals(
|
|
|
|
|
true,
|
|
|
|
@ -130,6 +130,26 @@ class NiaAppStateTest {
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun niaAppState_whenNetworkMonitorIsOnline_StateIsOnline() = runTest(UnconfinedTestDispatcher()) {
|
|
|
|
|
composeTestRule.setContent {
|
|
|
|
|
state = NiaAppState(
|
|
|
|
|
navController = NavHostController(LocalContext.current),
|
|
|
|
|
coroutineScope = backgroundScope,
|
|
|
|
|
errorMonitor = errorMonitor,
|
|
|
|
|
userNewsResourceRepository = userNewsResourceRepository,
|
|
|
|
|
timeZoneMonitor = timeZoneMonitor,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
backgroundScope.launch { state.isOfflineState.collect() }
|
|
|
|
|
networkMonitor.setConnected(true)
|
|
|
|
|
assertEquals(
|
|
|
|
|
false,
|
|
|
|
|
state.isOfflineState.value,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun niaAppState_differentTZ_withTimeZoneMonitorChange() = runTest(UnconfinedTestDispatcher()) {
|
|
|
|
|
composeTestRule.setContent {
|
|
|
|
|