use backgroundScope

Change-Id: I78d5e53d343dac7e7d27896c95714a53a9a7229a
pull/1400/head
hiroaki404 2 weeks ago
parent 94f86b7975
commit 8bb823ede7

@ -93,7 +93,7 @@ class BookmarksViewModelTest {
@Test
fun feedUiState_resourceIsViewed_setResourcesViewed() = runTest {
val collectJob = launch(UnconfinedTestDispatcher()) { viewModel.feedUiState.collect() }
backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.feedUiState.collect() }
// Given
newsRepository.sendNewsResources(newsResourcesTestData)
@ -109,13 +109,11 @@ class BookmarksViewModelTest {
val item = viewModel.feedUiState.value
assertIs<Success>(item)
assertTrue(item.feed.first().hasBeenViewed)
collectJob.cancel()
}
@Test
fun feedUiState_undoneBookmarkRemoval_bookmarkIsRestored() = runTest {
val collectJob = launch(UnconfinedTestDispatcher()) { viewModel.feedUiState.collect() }
launch(UnconfinedTestDispatcher()) { viewModel.feedUiState.collect() }
// Given
newsRepository.sendNewsResources(newsResourcesTestData)
@ -134,7 +132,5 @@ class BookmarksViewModelTest {
val item = viewModel.feedUiState.value
assertIs<Success>(item)
assertEquals(1, item.feed.size)
collectJob.cancel()
}
}

Loading…
Cancel
Save