Merge pull request #42 from madroidmaq/rename-ui-state

Rename UI State sealed interface class with UiState postfix
pull/55/head
Jolanda Verhoef 2 years ago committed by GitHub
commit c6397715d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -67,8 +67,8 @@ class ForYouScreenTest {
windowSizeClass = WindowSizeClass.calculateFromSize( windowSizeClass = WindowSizeClass.calculateFromSize(
DpSize(maxWidth, maxHeight) DpSize(maxWidth, maxHeight)
), ),
interestsSelectionState = ForYouInterestsSelectionState.Loading, interestsSelectionState = ForYouInterestsSelectionUiState.Loading,
feedState = ForYouFeedState.Loading, feedState = ForYouFeedUiState.Loading,
onAuthorCheckedChanged = { _, _ -> }, onAuthorCheckedChanged = { _, _ -> },
onTopicCheckedChanged = { _, _ -> }, onTopicCheckedChanged = { _, _ -> },
saveFollowedTopics = {}, saveFollowedTopics = {},
@ -92,7 +92,8 @@ class ForYouScreenTest {
windowSizeClass = WindowSizeClass.calculateFromSize( windowSizeClass = WindowSizeClass.calculateFromSize(
DpSize(maxWidth, maxHeight) DpSize(maxWidth, maxHeight)
), ),
interestsSelectionState = ForYouInterestsSelectionState.WithInterestsSelection( interestsSelectionState =
ForYouInterestsSelectionUiState.WithInterestsSelection(
topics = listOf( topics = listOf(
FollowableTopic( FollowableTopic(
topic = Topic( topic = Topic(
@ -153,7 +154,7 @@ class ForYouScreenTest {
), ),
) )
), ),
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = emptyList() feed = emptyList()
), ),
onAuthorCheckedChanged = { _, _ -> }, onAuthorCheckedChanged = { _, _ -> },
@ -200,7 +201,8 @@ class ForYouScreenTest {
windowSizeClass = WindowSizeClass.calculateFromSize( windowSizeClass = WindowSizeClass.calculateFromSize(
DpSize(maxWidth, maxHeight) DpSize(maxWidth, maxHeight)
), ),
interestsSelectionState = ForYouInterestsSelectionState.WithInterestsSelection( interestsSelectionState =
ForYouInterestsSelectionUiState.WithInterestsSelection(
topics = listOf( topics = listOf(
FollowableTopic( FollowableTopic(
topic = Topic( topic = Topic(
@ -261,7 +263,7 @@ class ForYouScreenTest {
), ),
), ),
), ),
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = emptyList() feed = emptyList()
), ),
onAuthorCheckedChanged = { _, _ -> }, onAuthorCheckedChanged = { _, _ -> },
@ -314,7 +316,8 @@ class ForYouScreenTest {
windowSizeClass = WindowSizeClass.calculateFromSize( windowSizeClass = WindowSizeClass.calculateFromSize(
DpSize(maxWidth, maxHeight) DpSize(maxWidth, maxHeight)
), ),
interestsSelectionState = ForYouInterestsSelectionState.WithInterestsSelection( interestsSelectionState =
ForYouInterestsSelectionUiState.WithInterestsSelection(
topics = listOf( topics = listOf(
FollowableTopic( FollowableTopic(
topic = Topic( topic = Topic(
@ -375,7 +378,7 @@ class ForYouScreenTest {
), ),
), ),
), ),
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = emptyList() feed = emptyList()
), ),
onAuthorCheckedChanged = { _, _ -> }, onAuthorCheckedChanged = { _, _ -> },
@ -428,7 +431,8 @@ class ForYouScreenTest {
windowSizeClass = WindowSizeClass.calculateFromSize( windowSizeClass = WindowSizeClass.calculateFromSize(
DpSize(maxWidth, maxHeight) DpSize(maxWidth, maxHeight)
), ),
interestsSelectionState = ForYouInterestsSelectionState.WithInterestsSelection( interestsSelectionState =
ForYouInterestsSelectionUiState.WithInterestsSelection(
topics = listOf( topics = listOf(
FollowableTopic( FollowableTopic(
topic = Topic( topic = Topic(
@ -489,7 +493,7 @@ class ForYouScreenTest {
), ),
), ),
), ),
feedState = ForYouFeedState.Loading, feedState = ForYouFeedUiState.Loading,
onAuthorCheckedChanged = { _, _ -> }, onAuthorCheckedChanged = { _, _ -> },
onTopicCheckedChanged = { _, _ -> }, onTopicCheckedChanged = { _, _ -> },
saveFollowedTopics = {}, saveFollowedTopics = {},
@ -523,8 +527,8 @@ class ForYouScreenTest {
windowSizeClass = WindowSizeClass.calculateFromSize( windowSizeClass = WindowSizeClass.calculateFromSize(
DpSize(maxWidth, maxHeight) DpSize(maxWidth, maxHeight)
), ),
interestsSelectionState = ForYouInterestsSelectionState.NoInterestsSelection, interestsSelectionState = ForYouInterestsSelectionUiState.NoInterestsSelection,
feedState = ForYouFeedState.Loading, feedState = ForYouFeedUiState.Loading,
onAuthorCheckedChanged = { _, _ -> }, onAuthorCheckedChanged = { _, _ -> },
onTopicCheckedChanged = { _, _ -> }, onTopicCheckedChanged = { _, _ -> },
saveFollowedTopics = {}, saveFollowedTopics = {},
@ -643,8 +647,8 @@ class ForYouScreenTest {
ForYouScreen( ForYouScreen(
windowSizeClass = windowSizeClass, windowSizeClass = windowSizeClass,
interestsSelectionState = ForYouInterestsSelectionState.NoInterestsSelection, interestsSelectionState = ForYouInterestsSelectionUiState.NoInterestsSelection,
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = saveableNewsResources feed = saveableNewsResources
), ),
onAuthorCheckedChanged = { _, _ -> }, onAuthorCheckedChanged = { _, _ -> },
@ -669,7 +673,10 @@ class ForYouScreenTest {
) )
val firstFeedItem = composeTestRule val firstFeedItem = composeTestRule
.onNodeWithText("Thanks for helping us reach 1M YouTube Subscribers", substring = true) .onNodeWithText(
"Thanks for helping us reach 1M YouTube Subscribers",
substring = true
)
.assertHasClickAction() .assertHasClickAction()
.fetchSemanticsNode() .fetchSemanticsNode()

@ -21,11 +21,11 @@ import com.google.samples.apps.nowinandroid.core.model.data.SaveableNewsResource
/** /**
* A sealed hierarchy describing the state of the feed on the for you screen. * A sealed hierarchy describing the state of the feed on the for you screen.
*/ */
sealed interface ForYouFeedState { sealed interface ForYouFeedUiState {
/** /**
* The feed is still loading. * The feed is still loading.
*/ */
object Loading : ForYouFeedState object Loading : ForYouFeedUiState
/** /**
* The feed is loaded with the given list of news resources. * The feed is loaded with the given list of news resources.
@ -35,5 +35,5 @@ sealed interface ForYouFeedState {
* The list of news resources contained in this [PopulatedFeed]. * The list of news resources contained in this [PopulatedFeed].
*/ */
val feed: List<SaveableNewsResource> val feed: List<SaveableNewsResource>
) : ForYouFeedState ) : ForYouFeedUiState
} }

@ -22,16 +22,16 @@ import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic
/** /**
* A sealed hierarchy describing the interests selection state for the for you screen. * A sealed hierarchy describing the interests selection state for the for you screen.
*/ */
sealed interface ForYouInterestsSelectionState { sealed interface ForYouInterestsSelectionUiState {
/** /**
* The interests selection state is loading. * The interests selection state is loading.
*/ */
object Loading : ForYouInterestsSelectionState object Loading : ForYouInterestsSelectionUiState
/** /**
* There is no interests selection state. * There is no interests selection state.
*/ */
object NoInterestsSelection : ForYouInterestsSelectionState object NoInterestsSelection : ForYouInterestsSelectionUiState
/** /**
* There is a interests selection state, with the given lists of topics and authors. * There is a interests selection state, with the given lists of topics and authors.
@ -39,7 +39,7 @@ sealed interface ForYouInterestsSelectionState {
data class WithInterestsSelection( data class WithInterestsSelection(
val topics: List<FollowableTopic>, val topics: List<FollowableTopic>,
val authors: List<FollowableAuthor> val authors: List<FollowableAuthor>
) : ForYouInterestsSelectionState { ) : ForYouInterestsSelectionUiState {
/** /**
* True if the current in-progress selection can be saved. * True if the current in-progress selection can be saved.
*/ */

@ -122,8 +122,8 @@ fun ForYouRoute(
@Composable @Composable
fun ForYouScreen( fun ForYouScreen(
windowSizeClass: WindowSizeClass, windowSizeClass: WindowSizeClass,
interestsSelectionState: ForYouInterestsSelectionState, interestsSelectionState: ForYouInterestsSelectionUiState,
feedState: ForYouFeedState, feedState: ForYouFeedUiState,
onTopicCheckedChanged: (String, Boolean) -> Unit, onTopicCheckedChanged: (String, Boolean) -> Unit,
onAuthorCheckedChanged: (String, Boolean) -> Unit, onAuthorCheckedChanged: (String, Boolean) -> Unit,
saveFollowedTopics: () -> Unit, saveFollowedTopics: () -> Unit,
@ -182,7 +182,7 @@ fun ForYouScreen(
// Avoid showing a second loading wheel if we already are for the interests // Avoid showing a second loading wheel if we already are for the interests
// selection // selection
showLoadingUIIfLoading = showLoadingUIIfLoading =
interestsSelectionState !is ForYouInterestsSelectionState.Loading, interestsSelectionState !is ForYouInterestsSelectionUiState.Loading,
numberOfColumns = numberOfColumns, numberOfColumns = numberOfColumns,
onNewsResourcesCheckedChanged = onNewsResourcesCheckedChanged onNewsResourcesCheckedChanged = onNewsResourcesCheckedChanged
) )
@ -211,14 +211,14 @@ fun ForYouScreen(
* states. * states.
*/ */
private fun LazyListScope.InterestsSelection( private fun LazyListScope.InterestsSelection(
interestsSelectionState: ForYouInterestsSelectionState, interestsSelectionState: ForYouInterestsSelectionUiState,
showLoadingUIIfLoading: Boolean, showLoadingUIIfLoading: Boolean,
onAuthorCheckedChanged: (String, Boolean) -> Unit, onAuthorCheckedChanged: (String, Boolean) -> Unit,
onTopicCheckedChanged: (String, Boolean) -> Unit, onTopicCheckedChanged: (String, Boolean) -> Unit,
saveFollowedTopics: () -> Unit saveFollowedTopics: () -> Unit
) { ) {
when (interestsSelectionState) { when (interestsSelectionState) {
ForYouInterestsSelectionState.Loading -> { ForYouInterestsSelectionUiState.Loading -> {
if (showLoadingUIIfLoading) { if (showLoadingUIIfLoading) {
item { item {
LoadingWheel( LoadingWheel(
@ -230,8 +230,8 @@ private fun LazyListScope.InterestsSelection(
} }
} }
} }
ForYouInterestsSelectionState.NoInterestsSelection -> Unit ForYouInterestsSelectionUiState.NoInterestsSelection -> Unit
is ForYouInterestsSelectionState.WithInterestsSelection -> { is ForYouInterestsSelectionUiState.WithInterestsSelection -> {
item { item {
Text( Text(
text = stringResource(R.string.onboarding_guidance_title), text = stringResource(R.string.onboarding_guidance_title),
@ -293,7 +293,7 @@ private fun LazyListScope.InterestsSelection(
@Composable @Composable
private fun TopicSelection( private fun TopicSelection(
interestsSelectionState: ForYouInterestsSelectionState.WithInterestsSelection, interestsSelectionState: ForYouInterestsSelectionUiState.WithInterestsSelection,
onTopicCheckedChanged: (String, Boolean) -> Unit, onTopicCheckedChanged: (String, Boolean) -> Unit,
modifier: Modifier = Modifier modifier: Modifier = Modifier
) { ) {
@ -407,13 +407,13 @@ fun TopicIcon(
* states. * states.
*/ */
private fun LazyListScope.Feed( private fun LazyListScope.Feed(
feedState: ForYouFeedState, feedState: ForYouFeedUiState,
showLoadingUIIfLoading: Boolean, showLoadingUIIfLoading: Boolean,
@IntRange(from = 1) numberOfColumns: Int, @IntRange(from = 1) numberOfColumns: Int,
onNewsResourcesCheckedChanged: (String, Boolean) -> Unit onNewsResourcesCheckedChanged: (String, Boolean) -> Unit
) { ) {
when (feedState) { when (feedState) {
ForYouFeedState.Loading -> { ForYouFeedUiState.Loading -> {
if (showLoadingUIIfLoading) { if (showLoadingUIIfLoading) {
item { item {
LoadingWheel( LoadingWheel(
@ -425,7 +425,7 @@ private fun LazyListScope.Feed(
} }
} }
} }
is ForYouFeedState.Success -> { is ForYouFeedUiState.Success -> {
items( items(
feedState.feed.chunked(numberOfColumns) feedState.feed.chunked(numberOfColumns)
) { saveableNewsResources -> ) { saveableNewsResources ->
@ -491,8 +491,8 @@ fun ForYouScreenLoading() {
NiaTheme { NiaTheme {
ForYouScreen( ForYouScreen(
windowSizeClass = WindowSizeClass.calculateFromSize(DpSize(maxWidth, maxHeight)), windowSizeClass = WindowSizeClass.calculateFromSize(DpSize(maxWidth, maxHeight)),
interestsSelectionState = ForYouInterestsSelectionState.Loading, interestsSelectionState = ForYouInterestsSelectionUiState.Loading,
feedState = ForYouFeedState.Loading, feedState = ForYouFeedUiState.Loading,
onTopicCheckedChanged = { _, _ -> }, onTopicCheckedChanged = { _, _ -> },
onAuthorCheckedChanged = { _, _ -> }, onAuthorCheckedChanged = { _, _ -> },
saveFollowedTopics = {}, saveFollowedTopics = {},
@ -512,7 +512,7 @@ fun ForYouScreenTopicSelection() {
NiaTheme { NiaTheme {
ForYouScreen( ForYouScreen(
windowSizeClass = WindowSizeClass.calculateFromSize(DpSize(maxWidth, maxHeight)), windowSizeClass = WindowSizeClass.calculateFromSize(DpSize(maxWidth, maxHeight)),
interestsSelectionState = ForYouInterestsSelectionState.WithInterestsSelection( interestsSelectionState = ForYouInterestsSelectionUiState.WithInterestsSelection(
topics = listOf( topics = listOf(
FollowableTopic( FollowableTopic(
topic = Topic( topic = Topic(
@ -584,7 +584,7 @@ fun ForYouScreenTopicSelection() {
) )
) )
), ),
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = saveableNewsResource, feed = saveableNewsResource,
), ),
onAuthorCheckedChanged = { _, _ -> }, onAuthorCheckedChanged = { _, _ -> },
@ -606,8 +606,8 @@ fun PopulatedFeed() {
NiaTheme { NiaTheme {
ForYouScreen( ForYouScreen(
windowSizeClass = WindowSizeClass.calculateFromSize(DpSize(maxWidth, maxHeight)), windowSizeClass = WindowSizeClass.calculateFromSize(DpSize(maxWidth, maxHeight)),
interestsSelectionState = ForYouInterestsSelectionState.NoInterestsSelection, interestsSelectionState = ForYouInterestsSelectionUiState.NoInterestsSelection,
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = saveableNewsResource feed = saveableNewsResource
), ),
onTopicCheckedChanged = { _, _ -> }, onTopicCheckedChanged = { _, _ -> },

@ -103,7 +103,7 @@ class ForYouViewModel @Inject constructor(
mutableStateOf<Set<String>>(emptySet()) mutableStateOf<Set<String>>(emptySet())
} }
val feedState: StateFlow<ForYouFeedState> = val feedState: StateFlow<ForYouFeedUiState> =
combine( combine(
followedInterestsState, followedInterestsState,
snapshotFlow { inProgressTopicSelection }, snapshotFlow { inProgressTopicSelection },
@ -114,7 +114,7 @@ class ForYouViewModel @Inject constructor(
when (followedInterestsUserState) { when (followedInterestsUserState) {
// If we don't know the current selection state, emit loading. // If we don't know the current selection state, emit loading.
Unknown -> flowOf<ForYouFeedState>(ForYouFeedState.Loading) Unknown -> flowOf<ForYouFeedUiState>(ForYouFeedUiState.Loading)
// If the user has followed topics, use those followed topics to populate the feed // If the user has followed topics, use those followed topics to populate the feed
is FollowedInterests -> { is FollowedInterests -> {
newsRepository.getNewsResourcesStream( newsRepository.getNewsResourcesStream(
@ -126,7 +126,7 @@ class ForYouViewModel @Inject constructor(
// on the in-progress interests selections, if there are any. // on the in-progress interests selections, if there are any.
None -> { None -> {
if (inProgressTopicSelection.isEmpty() && inProgressAuthorSelection.isEmpty()) { if (inProgressTopicSelection.isEmpty() && inProgressAuthorSelection.isEmpty()) {
flowOf<ForYouFeedState>(ForYouFeedState.Success(emptyList())) flowOf<ForYouFeedUiState>(ForYouFeedUiState.Success(emptyList()))
} else { } else {
newsRepository.getNewsResourcesStream( newsRepository.getNewsResourcesStream(
filterTopicIds = inProgressTopicSelection, filterTopicIds = inProgressTopicSelection,
@ -143,10 +143,10 @@ class ForYouViewModel @Inject constructor(
.stateIn( .stateIn(
scope = viewModelScope, scope = viewModelScope,
started = SharingStarted.WhileSubscribed(5_000), started = SharingStarted.WhileSubscribed(5_000),
initialValue = ForYouFeedState.Loading initialValue = ForYouFeedUiState.Loading
) )
val interestsSelectionState: StateFlow<ForYouInterestsSelectionState> = val interestsSelectionState: StateFlow<ForYouInterestsSelectionUiState> =
combine( combine(
followedInterestsState, followedInterestsState,
topicsRepository.getTopicsStream(), topicsRepository.getTopicsStream(),
@ -157,8 +157,8 @@ class ForYouViewModel @Inject constructor(
inProgressAuthorSelection -> inProgressAuthorSelection ->
when (followedInterestsUserState) { when (followedInterestsUserState) {
Unknown -> ForYouInterestsSelectionState.Loading Unknown -> ForYouInterestsSelectionUiState.Loading
is FollowedInterests -> ForYouInterestsSelectionState.NoInterestsSelection is FollowedInterests -> ForYouInterestsSelectionUiState.NoInterestsSelection
None -> { None -> {
val topics = availableTopics.map { topic -> val topics = availableTopics.map { topic ->
FollowableTopic( FollowableTopic(
@ -174,9 +174,9 @@ class ForYouViewModel @Inject constructor(
} }
if (topics.isEmpty() && authors.isEmpty()) { if (topics.isEmpty() && authors.isEmpty()) {
ForYouInterestsSelectionState.Loading ForYouInterestsSelectionUiState.Loading
} else { } else {
ForYouInterestsSelectionState.WithInterestsSelection( ForYouInterestsSelectionUiState.WithInterestsSelection(
topics = topics, topics = topics,
authors = authors authors = authors
) )
@ -187,7 +187,7 @@ class ForYouViewModel @Inject constructor(
.stateIn( .stateIn(
scope = viewModelScope, scope = viewModelScope,
started = SharingStarted.WhileSubscribed(5_000), started = SharingStarted.WhileSubscribed(5_000),
initialValue = ForYouInterestsSelectionState.Loading initialValue = ForYouInterestsSelectionUiState.Loading
) )
fun updateTopicSelection(topicId: String, isChecked: Boolean) { fun updateTopicSelection(topicId: String, isChecked: Boolean) {
@ -245,7 +245,7 @@ class ForYouViewModel @Inject constructor(
private fun Flow<List<NewsResource>>.mapToFeedState( private fun Flow<List<NewsResource>>.mapToFeedState(
savedNewsResources: Set<String> savedNewsResources: Set<String>
): Flow<ForYouFeedState> = ): Flow<ForYouFeedUiState> =
filterNot { it.isEmpty() } filterNot { it.isEmpty() }
.map { newsResources -> .map { newsResources ->
newsResources.map { newsResource -> newsResources.map { newsResource ->
@ -255,5 +255,5 @@ private fun Flow<List<NewsResource>>.mapToFeedState(
) )
} }
} }
.map<List<SaveableNewsResource>, ForYouFeedState>(ForYouFeedState::Success) .map<List<SaveableNewsResource>, ForYouFeedUiState>(ForYouFeedUiState::Success)
.onStart { emit(ForYouFeedState.Loading) } .onStart { emit(ForYouFeedUiState.Loading) }

@ -58,12 +58,12 @@ class ForYouViewModelTest {
} }
/** /**
* A pairing of [ForYouInterestsSelectionState] and [ForYouFeedState] for ease of testing * A pairing of [ForYouInterestsSelectionUiState] and [ForYouFeedUiState] for ease of testing
* state updates as a single flow. * state updates as a single flow.
*/ */
private data class ForYouUiState( private data class ForYouUiState(
val interestsSelectionState: ForYouInterestsSelectionState, val interestsSelectionState: ForYouInterestsSelectionUiState,
val feedState: ForYouFeedState, val feedState: ForYouFeedUiState,
) )
private val ForYouViewModel.uiState private val ForYouViewModel.uiState
@ -79,8 +79,8 @@ class ForYouViewModelTest {
viewModel.uiState.test { viewModel.uiState.test {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
ForYouInterestsSelectionState.Loading, ForYouInterestsSelectionUiState.Loading,
ForYouFeedState.Loading ForYouFeedUiState.Loading
), ),
awaitItem() awaitItem()
) )
@ -93,8 +93,8 @@ class ForYouViewModelTest {
viewModel.uiState.test { viewModel.uiState.test {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
ForYouInterestsSelectionState.Loading, ForYouInterestsSelectionUiState.Loading,
ForYouFeedState.Loading ForYouFeedUiState.Loading
), ),
awaitItem() awaitItem()
) )
@ -109,8 +109,8 @@ class ForYouViewModelTest {
viewModel.uiState.test { viewModel.uiState.test {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
ForYouInterestsSelectionState.Loading, ForYouInterestsSelectionUiState.Loading,
ForYouFeedState.Loading ForYouFeedUiState.Loading
), ),
awaitItem() awaitItem()
) )
@ -125,8 +125,8 @@ class ForYouViewModelTest {
viewModel.uiState.test { viewModel.uiState.test {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
ForYouInterestsSelectionState.Loading, ForYouInterestsSelectionUiState.Loading,
ForYouFeedState.Loading ForYouFeedUiState.Loading
), ),
awaitItem() awaitItem()
) )
@ -141,8 +141,8 @@ class ForYouViewModelTest {
viewModel.uiState.test { viewModel.uiState.test {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
ForYouInterestsSelectionState.Loading, ForYouInterestsSelectionUiState.Loading,
ForYouFeedState.Loading ForYouFeedUiState.Loading
), ),
awaitItem() awaitItem()
) )
@ -166,7 +166,7 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.WithInterestsSelection( ForYouInterestsSelectionUiState.WithInterestsSelection(
topics = listOf( topics = listOf(
FollowableTopic( FollowableTopic(
topic = Topic( topic = Topic(
@ -238,7 +238,7 @@ class ForYouViewModelTest {
) )
), ),
), ),
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = emptyList() feed = emptyList()
) )
), ),
@ -263,7 +263,7 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.WithInterestsSelection( ForYouInterestsSelectionUiState.WithInterestsSelection(
topics = listOf( topics = listOf(
FollowableTopic( FollowableTopic(
topic = Topic( topic = Topic(
@ -335,7 +335,7 @@ class ForYouViewModelTest {
) )
), ),
), ),
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = emptyList() feed = emptyList()
) )
), ),
@ -359,8 +359,8 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.NoInterestsSelection, ForYouInterestsSelectionUiState.NoInterestsSelection,
feedState = ForYouFeedState.Loading feedState = ForYouFeedUiState.Loading
), ),
awaitItem() awaitItem()
) )
@ -370,8 +370,8 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.NoInterestsSelection, ForYouInterestsSelectionUiState.NoInterestsSelection,
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = sampleNewsResources.map { feed = sampleNewsResources.map {
SaveableNewsResource( SaveableNewsResource(
newsResource = it, newsResource = it,
@ -400,8 +400,8 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.NoInterestsSelection, ForYouInterestsSelectionUiState.NoInterestsSelection,
feedState = ForYouFeedState.Loading feedState = ForYouFeedUiState.Loading
), ),
awaitItem() awaitItem()
) )
@ -411,8 +411,8 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.NoInterestsSelection, ForYouInterestsSelectionUiState.NoInterestsSelection,
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = sampleNewsResources.map { feed = sampleNewsResources.map {
SaveableNewsResource( SaveableNewsResource(
newsResource = it, newsResource = it,
@ -445,7 +445,7 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.WithInterestsSelection( ForYouInterestsSelectionUiState.WithInterestsSelection(
topics = listOf( topics = listOf(
FollowableTopic( FollowableTopic(
topic = Topic( topic = Topic(
@ -517,7 +517,7 @@ class ForYouViewModelTest {
) )
), ),
), ),
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = emptyList(), feed = emptyList(),
) )
), ),
@ -526,7 +526,7 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.WithInterestsSelection( ForYouInterestsSelectionUiState.WithInterestsSelection(
topics = listOf( topics = listOf(
FollowableTopic( FollowableTopic(
topic = Topic( topic = Topic(
@ -598,14 +598,14 @@ class ForYouViewModelTest {
) )
), ),
), ),
feedState = ForYouFeedState.Loading feedState = ForYouFeedUiState.Loading
), ),
awaitItem() awaitItem()
) )
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.WithInterestsSelection( ForYouInterestsSelectionUiState.WithInterestsSelection(
topics = listOf( topics = listOf(
FollowableTopic( FollowableTopic(
topic = Topic( topic = Topic(
@ -677,7 +677,7 @@ class ForYouViewModelTest {
) )
), ),
), ),
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = listOf( feed = listOf(
SaveableNewsResource( SaveableNewsResource(
newsResource = sampleNewsResources[1], newsResource = sampleNewsResources[1],
@ -714,7 +714,7 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.WithInterestsSelection( ForYouInterestsSelectionUiState.WithInterestsSelection(
topics = listOf( topics = listOf(
FollowableTopic( FollowableTopic(
topic = Topic( topic = Topic(
@ -786,7 +786,7 @@ class ForYouViewModelTest {
) )
), ),
), ),
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = emptyList(), feed = emptyList(),
) )
), ),
@ -795,7 +795,7 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.WithInterestsSelection( ForYouInterestsSelectionUiState.WithInterestsSelection(
topics = listOf( topics = listOf(
FollowableTopic( FollowableTopic(
topic = Topic( topic = Topic(
@ -867,14 +867,14 @@ class ForYouViewModelTest {
) )
), ),
), ),
feedState = ForYouFeedState.Loading feedState = ForYouFeedUiState.Loading
), ),
awaitItem() awaitItem()
) )
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.WithInterestsSelection( ForYouInterestsSelectionUiState.WithInterestsSelection(
topics = listOf( topics = listOf(
FollowableTopic( FollowableTopic(
topic = Topic( topic = Topic(
@ -946,7 +946,7 @@ class ForYouViewModelTest {
) )
), ),
), ),
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = listOf( feed = listOf(
SaveableNewsResource( SaveableNewsResource(
newsResource = sampleNewsResources[1], newsResource = sampleNewsResources[1],
@ -981,7 +981,7 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.WithInterestsSelection( ForYouInterestsSelectionUiState.WithInterestsSelection(
topics = listOf( topics = listOf(
FollowableTopic( FollowableTopic(
topic = Topic( topic = Topic(
@ -1053,7 +1053,7 @@ class ForYouViewModelTest {
) )
), ),
), ),
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = emptyList() feed = emptyList()
) )
), ),
@ -1079,7 +1079,7 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.WithInterestsSelection( ForYouInterestsSelectionUiState.WithInterestsSelection(
topics = listOf( topics = listOf(
FollowableTopic( FollowableTopic(
topic = Topic( topic = Topic(
@ -1151,7 +1151,7 @@ class ForYouViewModelTest {
) )
), ),
), ),
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = emptyList() feed = emptyList()
) )
), ),
@ -1181,8 +1181,8 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.NoInterestsSelection, ForYouInterestsSelectionUiState.NoInterestsSelection,
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = listOf( feed = listOf(
SaveableNewsResource( SaveableNewsResource(
newsResource = sampleNewsResources[1], newsResource = sampleNewsResources[1],
@ -1223,8 +1223,8 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.NoInterestsSelection, ForYouInterestsSelectionUiState.NoInterestsSelection,
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = listOf( feed = listOf(
SaveableNewsResource( SaveableNewsResource(
newsResource = sampleNewsResources[0], newsResource = sampleNewsResources[0],
@ -1262,8 +1262,8 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.NoInterestsSelection, ForYouInterestsSelectionUiState.NoInterestsSelection,
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = listOf( feed = listOf(
SaveableNewsResource( SaveableNewsResource(
newsResource = sampleNewsResources[1], newsResource = sampleNewsResources[1],
@ -1305,7 +1305,7 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.WithInterestsSelection( ForYouInterestsSelectionUiState.WithInterestsSelection(
topics = listOf( topics = listOf(
FollowableTopic( FollowableTopic(
topic = Topic( topic = Topic(
@ -1377,7 +1377,7 @@ class ForYouViewModelTest {
) )
) )
), ),
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = emptyList() feed = emptyList()
) )
), ),
@ -1409,7 +1409,7 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.WithInterestsSelection( ForYouInterestsSelectionUiState.WithInterestsSelection(
topics = listOf( topics = listOf(
FollowableTopic( FollowableTopic(
topic = Topic( topic = Topic(
@ -1481,7 +1481,7 @@ class ForYouViewModelTest {
) )
) )
), ),
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = emptyList() feed = emptyList()
) )
), ),
@ -1506,8 +1506,8 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
ForYouUiState( ForYouUiState(
interestsSelectionState = interestsSelectionState =
ForYouInterestsSelectionState.NoInterestsSelection, ForYouInterestsSelectionUiState.NoInterestsSelection,
feedState = ForYouFeedState.Success( feedState = ForYouFeedUiState.Success(
feed = listOf( feed = listOf(
SaveableNewsResource( SaveableNewsResource(
newsResource = sampleNewsResources[1], newsResource = sampleNewsResources[1],

Loading…
Cancel
Save