|
|
|
@ -53,6 +53,9 @@ class GetUserNewsResourcesUseCaseTest {
|
|
|
|
|
setOf(sampleNewsResources[0].id, sampleNewsResources[2].id)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Set a followed topic for the user.
|
|
|
|
|
userDataRepository.setFollowedTopicIds(setOf(sampleTopic1.id))
|
|
|
|
|
|
|
|
|
|
// Check that the correct news resources are returned with their bookmarked state.
|
|
|
|
|
assertEquals(
|
|
|
|
|
listOf(
|
|
|
|
@ -67,7 +70,7 @@ class GetUserNewsResourcesUseCaseTest {
|
|
|
|
|
sampleNewsResources[0].topics.map { topic ->
|
|
|
|
|
FollowableTopic(
|
|
|
|
|
topic = topic,
|
|
|
|
|
isFollowed = false
|
|
|
|
|
isFollowed = topic.id == sampleTopic1.id
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
true
|
|
|
|
@ -83,7 +86,7 @@ class GetUserNewsResourcesUseCaseTest {
|
|
|
|
|
sampleNewsResources[1].topics.map { topic ->
|
|
|
|
|
FollowableTopic(
|
|
|
|
|
topic = topic,
|
|
|
|
|
isFollowed = false
|
|
|
|
|
isFollowed = topic.id == sampleTopic1.id
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
false
|
|
|
|
@ -99,7 +102,7 @@ class GetUserNewsResourcesUseCaseTest {
|
|
|
|
|
sampleNewsResources[2].topics.map { topic ->
|
|
|
|
|
FollowableTopic(
|
|
|
|
|
topic = topic,
|
|
|
|
|
isFollowed = false
|
|
|
|
|
isFollowed = topic.id == sampleTopic1.id
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
true
|
|
|
|
@ -144,74 +147,6 @@ class GetUserNewsResourcesUseCaseTest {
|
|
|
|
|
saveableNewsResources.first()
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun checkNewsResourcesContainCorrectFollowedTopics() = runTest {
|
|
|
|
|
|
|
|
|
|
// Obtain the saveable news resources stream.
|
|
|
|
|
val saveableNewsResources = useCase()
|
|
|
|
|
|
|
|
|
|
// Send some news resources.
|
|
|
|
|
newsRepository.sendNewsResources(sampleNewsResources)
|
|
|
|
|
|
|
|
|
|
// Set a followed topic for the user.
|
|
|
|
|
userDataRepository.setFollowedTopicIds(setOf(sampleTopic1.id))
|
|
|
|
|
|
|
|
|
|
// Check that the followed topic is marked followed in the UserNewsResources
|
|
|
|
|
assertEquals(
|
|
|
|
|
listOf(
|
|
|
|
|
UserNewsResource(
|
|
|
|
|
sampleNewsResources[0].id,
|
|
|
|
|
sampleNewsResources[0].title,
|
|
|
|
|
sampleNewsResources[0].content,
|
|
|
|
|
sampleNewsResources[0].url,
|
|
|
|
|
sampleNewsResources[0].headerImageUrl,
|
|
|
|
|
sampleNewsResources[0].publishDate,
|
|
|
|
|
sampleNewsResources[0].type,
|
|
|
|
|
sampleNewsResources[0].topics.map { topic ->
|
|
|
|
|
FollowableTopic(
|
|
|
|
|
topic = topic,
|
|
|
|
|
isFollowed = topic.id == sampleTopic1.id
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
false
|
|
|
|
|
),
|
|
|
|
|
UserNewsResource(
|
|
|
|
|
sampleNewsResources[1].id,
|
|
|
|
|
sampleNewsResources[1].title,
|
|
|
|
|
sampleNewsResources[1].content,
|
|
|
|
|
sampleNewsResources[1].url,
|
|
|
|
|
sampleNewsResources[1].headerImageUrl,
|
|
|
|
|
sampleNewsResources[1].publishDate,
|
|
|
|
|
sampleNewsResources[1].type,
|
|
|
|
|
sampleNewsResources[1].topics.map { topic ->
|
|
|
|
|
FollowableTopic(
|
|
|
|
|
topic = topic,
|
|
|
|
|
isFollowed = topic.id == sampleTopic1.id
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
false
|
|
|
|
|
),
|
|
|
|
|
UserNewsResource(
|
|
|
|
|
sampleNewsResources[2].id,
|
|
|
|
|
sampleNewsResources[2].title,
|
|
|
|
|
sampleNewsResources[2].content,
|
|
|
|
|
sampleNewsResources[2].url,
|
|
|
|
|
sampleNewsResources[2].headerImageUrl,
|
|
|
|
|
sampleNewsResources[2].publishDate,
|
|
|
|
|
sampleNewsResources[2].type,
|
|
|
|
|
sampleNewsResources[2].topics.map { topic ->
|
|
|
|
|
FollowableTopic(
|
|
|
|
|
topic = topic,
|
|
|
|
|
isFollowed = topic.id == sampleTopic1.id
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
false
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
saveableNewsResources.first()
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private val sampleTopic1 = Topic(
|
|
|
|
|