|
|
@ -91,7 +91,7 @@ class AuthorViewModelTest {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun uiStateNews_whenInitialized_thenShowLoading() = runTest {
|
|
|
|
fun uiStateNews_whenInitialized_thenShowLoading() = runTest {
|
|
|
|
assertEquals(NewsUiState.Loading, viewModel.newUiState.value)
|
|
|
|
assertEquals(NewsUiState.Loading, viewModel.newsUiState.value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
@ -115,7 +115,7 @@ class AuthorViewModelTest {
|
|
|
|
val collectJob = launch(UnconfinedTestDispatcher()) {
|
|
|
|
val collectJob = launch(UnconfinedTestDispatcher()) {
|
|
|
|
combine(
|
|
|
|
combine(
|
|
|
|
viewModel.authorUiState,
|
|
|
|
viewModel.authorUiState,
|
|
|
|
viewModel.newUiState,
|
|
|
|
viewModel.newsUiState,
|
|
|
|
::Pair
|
|
|
|
::Pair
|
|
|
|
).collect()
|
|
|
|
).collect()
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -123,7 +123,7 @@ class AuthorViewModelTest {
|
|
|
|
authorsRepository.sendAuthors(testInputAuthors.map { it.author })
|
|
|
|
authorsRepository.sendAuthors(testInputAuthors.map { it.author })
|
|
|
|
userDataRepository.setFollowedAuthorIds(setOf(testInputAuthors[1].author.id))
|
|
|
|
userDataRepository.setFollowedAuthorIds(setOf(testInputAuthors[1].author.id))
|
|
|
|
val authorState = viewModel.authorUiState.value
|
|
|
|
val authorState = viewModel.authorUiState.value
|
|
|
|
val newsUiState = viewModel.newUiState.value
|
|
|
|
val newsUiState = viewModel.newsUiState.value
|
|
|
|
|
|
|
|
|
|
|
|
assertTrue(authorState is AuthorUiState.Success)
|
|
|
|
assertTrue(authorState is AuthorUiState.Success)
|
|
|
|
assertTrue(newsUiState is NewsUiState.Loading)
|
|
|
|
assertTrue(newsUiState is NewsUiState.Loading)
|
|
|
@ -137,7 +137,7 @@ class AuthorViewModelTest {
|
|
|
|
val collectJob = launch(UnconfinedTestDispatcher()) {
|
|
|
|
val collectJob = launch(UnconfinedTestDispatcher()) {
|
|
|
|
combine(
|
|
|
|
combine(
|
|
|
|
viewModel.authorUiState,
|
|
|
|
viewModel.authorUiState,
|
|
|
|
viewModel.newUiState,
|
|
|
|
viewModel.newsUiState,
|
|
|
|
::Pair
|
|
|
|
::Pair
|
|
|
|
).collect()
|
|
|
|
).collect()
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -146,7 +146,7 @@ class AuthorViewModelTest {
|
|
|
|
userDataRepository.setFollowedAuthorIds(setOf(testInputAuthors[1].author.id))
|
|
|
|
userDataRepository.setFollowedAuthorIds(setOf(testInputAuthors[1].author.id))
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
val authorState = viewModel.authorUiState.value
|
|
|
|
val authorState = viewModel.authorUiState.value
|
|
|
|
val newsUiState = viewModel.newUiState.value
|
|
|
|
val newsUiState = viewModel.newsUiState.value
|
|
|
|
|
|
|
|
|
|
|
|
assertTrue(authorState is AuthorUiState.Success)
|
|
|
|
assertTrue(authorState is AuthorUiState.Success)
|
|
|
|
assertTrue(newsUiState is NewsUiState.Success)
|
|
|
|
assertTrue(newsUiState is NewsUiState.Success)
|
|
|
@ -174,7 +174,7 @@ class AuthorViewModelTest {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun uiStateAuthor_whenNewsBookmarked_thenShowBookmarkedNews() = runTest {
|
|
|
|
fun uiStateAuthor_whenNewsBookmarked_thenShowBookmarkedNews() = runTest {
|
|
|
|
val collectJob = launch(UnconfinedTestDispatcher()) { viewModel.newUiState.collect() }
|
|
|
|
val collectJob = launch(UnconfinedTestDispatcher()) { viewModel.newsUiState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
authorsRepository.sendAuthors(testInputAuthors.map { it.author })
|
|
|
|
authorsRepository.sendAuthors(testInputAuthors.map { it.author })
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
@ -191,7 +191,7 @@ class AuthorViewModelTest {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
assertTrue(
|
|
|
|
assertTrue(
|
|
|
|
(viewModel.newUiState.value as NewsUiState.Success)
|
|
|
|
(viewModel.newsUiState.value as NewsUiState.Success)
|
|
|
|
.news
|
|
|
|
.news
|
|
|
|
.first { it.newsResource.id == sampleNewsResources.first().id }
|
|
|
|
.first { it.newsResource.id == sampleNewsResources.first().id }
|
|
|
|
.isSaved
|
|
|
|
.isSaved
|
|
|
|