Added third draft of tests

pull/521/head
magicalmeghan 2 years ago
parent d9e18607be
commit ffb5aeba86

@ -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(

@ -89,4 +89,5 @@ class NewsResourceCardTest {
.onNodeWithText(followableTopics[1].topic.name)
.assertContentDescriptionEquals("UI is followed")
}
//TODO add a test for not followed - figure out whether to put it here or to make a new test
}
Loading…
Cancel
Save