use backgroundScope

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

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

Loading…
Cancel
Save