Merge remote-tracking branch 'github/mm/chipcolor' into mm/chipcolor

pull/508/head
magicalmeghan 2 years ago
commit de6a4ec6c7

@ -17,14 +17,12 @@
package com.google.samples.apps.nowinandroid.core.domain
import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig.FOLLOW_SYSTEM
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Video
import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand.DEFAULT
import com.google.samples.apps.nowinandroid.core.model.data.Topic
import com.google.samples.apps.nowinandroid.core.model.data.UserData
import com.google.samples.apps.nowinandroid.core.testing.repository.TestNewsRepository
import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository
import com.google.samples.apps.nowinandroid.core.testing.repository.emptyUserData
import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule
import kotlin.test.assertEquals
import kotlinx.coroutines.flow.first
@ -53,12 +51,9 @@ class GetUserNewsResourcesUseCaseTest {
newsRepository.sendNewsResources(sampleNewsResources)
// Construct the test user data with bookmarks and followed topics.
val userData = UserData(
val userData = emptyUserData.copy(
bookmarkedNewsResources = setOf(sampleNewsResources[0].id, sampleNewsResources[2].id),
followedTopics = setOf(sampleTopic1.id),
themeBrand = DEFAULT,
darkThemeConfig = FOLLOW_SYSTEM,
shouldHideOnboarding = false
followedTopics = setOf(sampleTopic1.id)
)
userDataRepository.setUserData(userData)
@ -82,21 +77,14 @@ class GetUserNewsResourcesUseCaseTest {
// Send test data into the repositories.
newsRepository.sendNewsResources(sampleNewsResources)
val userData = UserData(
bookmarkedNewsResources = emptySet(),
followedTopics = emptySet(),
themeBrand = DEFAULT,
darkThemeConfig = FOLLOW_SYSTEM,
shouldHideOnboarding = false
)
userDataRepository.setUserData(userData)
userDataRepository.setUserData(emptyUserData)
// Check that only news resources with the given topic id are returned.
assertEquals(
sampleNewsResources
.filter { it.topics.contains(sampleTopic1) }
.map {
UserNewsResource(it, userData)
UserNewsResource(it, emptyUserData)
},
userNewsResources.first()
)

@ -84,7 +84,7 @@ class NewsResourceCardTest {
NewsResourceTopics(topics = previewFollowableTopics)
}
for(followableTopic in previewFollowableTopics){
for (followableTopic in previewFollowableTopics) {
val topicName = followableTopic.topic.name
val expectedContentDescription = if (followableTopic.isFollowed) {
"$topicName is followed"

@ -26,8 +26,10 @@ import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performScrollToNode
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic
import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Video
import com.google.samples.apps.nowinandroid.core.model.data.Topic
import com.google.samples.apps.nowinandroid.core.testing.repository.emptyUserData
import kotlinx.datetime.Instant
import org.junit.Before
import org.junit.Rule
@ -177,29 +179,29 @@ private val testTopics = listOf(
private val sampleUserNewsResources = listOf(
UserNewsResource(
id = "1",
title = "Thanks for helping us reach 1M YouTube Subscribers",
content = "Thank you everyone for following the Now in Android series and everything the " +
"Android Developers YouTube channel has to offer. During the Android Developer " +
"Summit, our YouTube channel reached 1 million subscribers! Heres a small video to " +
"thank you all.",
url = "https://youtu.be/-fJ6poHQrjM",
headerImageUrl = "https://i.ytimg.com/vi/-fJ6poHQrjM/maxresdefault.jpg",
publishDate = Instant.parse("2021-11-09T00:00:00.000Z"),
type = Video,
followableTopics = listOf(
FollowableTopic(
topic = Topic(
newsResource =
NewsResource(
id = "1",
title = "Thanks for helping us reach 1M YouTube Subscribers",
content = "Thank you everyone for following the Now in Android series and" +
" everything the Android Developers YouTube channel has to offer. During the " +
"Android Developer Summit, our YouTube channel reached 1 million subscribers!" +
" Heres a small video to thank you all.",
url = "https://youtu.be/-fJ6poHQrjM",
headerImageUrl = "https://i.ytimg.com/vi/-fJ6poHQrjM/maxresdefault.jpg",
publishDate = Instant.parse("2021-11-09T00:00:00.000Z"),
type = Video,
topics = listOf(
Topic(
id = "0",
name = "Headlines",
shortDescription = "",
longDescription = TOPIC_DESC,
url = "",
imageUrl = ""
),
isFollowed = false
)
)
),
isSaved = true
userData = emptyUserData.copy(bookmarkedNewsResources = setOf("1"))
)
)

Loading…
Cancel
Save