|
|
@ -98,9 +98,8 @@ class ForYouViewModelTest {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun stateIsLoadingWhenFollowedTopicsAreLoading() = runTest {
|
|
|
|
fun stateIsLoadingWhenFollowedTopicsAreLoading() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
|
|
|
|
|
|
|
@ -110,30 +109,25 @@ class ForYouViewModelTest {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assertEquals(NewsFeedUiState.Loading, viewModel.feedState.value)
|
|
|
|
assertEquals(NewsFeedUiState.Loading, viewModel.feedState.value)
|
|
|
|
|
|
|
|
|
|
|
|
collectJob1.cancel()
|
|
|
|
|
|
|
|
collectJob2.cancel()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun stateIsLoadingWhenAppIsSyncingWithNoInterests() = runTest {
|
|
|
|
fun stateIsLoadingWhenAppIsSyncingWithNoInterests() = runTest {
|
|
|
|
syncManager.setSyncing(true)
|
|
|
|
syncManager.setSyncing(true)
|
|
|
|
|
|
|
|
|
|
|
|
val collectJob =
|
|
|
|
backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.isSyncing.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.isSyncing.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
viewModel.isSyncing.value,
|
|
|
|
viewModel.isSyncing.value,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
collectJob.cancel()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun onboardingStateIsLoadingWhenTopicsAreLoading() = runTest {
|
|
|
|
fun onboardingStateIsLoadingWhenTopicsAreLoading() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
userDataRepository.setFollowedTopicIds(emptySet())
|
|
|
|
userDataRepository.setFollowedTopicIds(emptySet())
|
|
|
|
|
|
|
|
|
|
|
@ -142,16 +136,13 @@ class ForYouViewModelTest {
|
|
|
|
viewModel.onboardingUiState.value,
|
|
|
|
viewModel.onboardingUiState.value,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assertEquals(NewsFeedUiState.Success(emptyList()), viewModel.feedState.value)
|
|
|
|
assertEquals(NewsFeedUiState.Success(emptyList()), viewModel.feedState.value)
|
|
|
|
|
|
|
|
|
|
|
|
collectJob1.cancel()
|
|
|
|
|
|
|
|
collectJob2.cancel()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun onboardingIsShownWhenNewsResourcesAreLoading() = runTest {
|
|
|
|
fun onboardingIsShownWhenNewsResourcesAreLoading() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
userDataRepository.setFollowedTopicIds(emptySet())
|
|
|
|
userDataRepository.setFollowedTopicIds(emptySet())
|
|
|
@ -202,16 +193,12 @@ class ForYouViewModelTest {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
viewModel.feedState.value,
|
|
|
|
viewModel.feedState.value,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
collectJob1.cancel()
|
|
|
|
|
|
|
|
collectJob2.cancel()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun onboardingIsShownAfterLoadingEmptyFollowedTopics() = runTest {
|
|
|
|
fun onboardingIsShownAfterLoadingEmptyFollowedTopics() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
userDataRepository.setFollowedTopicIds(emptySet())
|
|
|
|
userDataRepository.setFollowedTopicIds(emptySet())
|
|
|
@ -264,15 +251,12 @@ class ForYouViewModelTest {
|
|
|
|
viewModel.feedState.value,
|
|
|
|
viewModel.feedState.value,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
collectJob1.cancel()
|
|
|
|
|
|
|
|
collectJob2.cancel()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun onboardingIsNotShownAfterUserDismissesOnboarding() = runTest {
|
|
|
|
fun onboardingIsNotShownAfterUserDismissesOnboarding() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
|
|
|
|
|
|
|
@ -300,15 +284,13 @@ class ForYouViewModelTest {
|
|
|
|
viewModel.feedState.value,
|
|
|
|
viewModel.feedState.value,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
collectJob1.cancel()
|
|
|
|
|
|
|
|
collectJob2.cancel()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun topicSelectionUpdatesAfterSelectingTopic() = runTest {
|
|
|
|
fun topicSelectionUpdatesAfterSelectingTopic() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
userDataRepository.setFollowedTopicIds(emptySet())
|
|
|
|
userDataRepository.setFollowedTopicIds(emptySet())
|
|
|
@ -352,16 +334,12 @@ class ForYouViewModelTest {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
viewModel.feedState.value,
|
|
|
|
viewModel.feedState.value,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
collectJob1.cancel()
|
|
|
|
|
|
|
|
collectJob2.cancel()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun topicSelectionUpdatesAfterUnselectingTopic() = runTest {
|
|
|
|
fun topicSelectionUpdatesAfterUnselectingTopic() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
topicsRepository.sendTopics(sampleTopics)
|
|
|
|
userDataRepository.setFollowedTopicIds(emptySet())
|
|
|
|
userDataRepository.setFollowedTopicIds(emptySet())
|
|
|
@ -416,16 +394,12 @@ class ForYouViewModelTest {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
viewModel.feedState.value,
|
|
|
|
viewModel.feedState.value,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
collectJob1.cancel()
|
|
|
|
|
|
|
|
collectJob2.cancel()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun newsResourceSelectionUpdatesAfterLoadingFollowedTopics() = runTest {
|
|
|
|
fun newsResourceSelectionUpdatesAfterLoadingFollowedTopics() = runTest {
|
|
|
|
val collectJob1 =
|
|
|
|
backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.onboardingUiState.collect() }
|
|
|
|
backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
val collectJob2 = launch(UnconfinedTestDispatcher()) { viewModel.feedState.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val followedTopicIds = setOf("1")
|
|
|
|
val followedTopicIds = setOf("1")
|
|
|
|
val userData = emptyUserData.copy(
|
|
|
|
val userData = emptyUserData.copy(
|
|
|
@ -461,14 +435,11 @@ class ForYouViewModelTest {
|
|
|
|
viewModel.feedState.value,
|
|
|
|
viewModel.feedState.value,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
collectJob1.cancel()
|
|
|
|
|
|
|
|
collectJob2.cancel()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun deepLinkedNewsResourceIsFetchedAndResetAfterViewing() = runTest {
|
|
|
|
fun deepLinkedNewsResourceIsFetchedAndResetAfterViewing() = runTest {
|
|
|
|
val collectJob =
|
|
|
|
backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.deepLinkedNewsResource.collect() }
|
|
|
|
launch(UnconfinedTestDispatcher()) { viewModel.deepLinkedNewsResource.collect() }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
userDataRepository.setUserData(emptyUserData)
|
|
|
|
userDataRepository.setUserData(emptyUserData)
|
|
|
@ -504,7 +475,6 @@ class ForYouViewModelTest {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
collectJob.cancel()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|