pull/301/head
Caren Chang 2 years ago
parent 31189f3328
commit 6b2d93d42c

@ -27,6 +27,7 @@ import androidx.compose.ui.test.performScrollToNode
import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic
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.SaveableNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.Topic
import kotlinx.datetime.Instant
import org.junit.Before
@ -57,9 +58,10 @@ class TopicScreenTest {
composeTestRule.setContent {
TopicScreen(
topicState = TopicUiState.Loading,
newsState = NewsUiState.Loading,
newsUiState = NewsUiState.Loading,
onBackClick = { },
onFollowClick = { }
onFollowClick = { },
onBookmarkChanged = { _, _ -> },
)
}
@ -74,9 +76,10 @@ class TopicScreenTest {
composeTestRule.setContent {
TopicScreen(
topicState = TopicUiState.Success(testTopic),
newsState = NewsUiState.Loading,
newsUiState = NewsUiState.Loading,
onBackClick = { },
onFollowClick = { }
onFollowClick = { },
onBookmarkChanged = { _, _ -> },
)
}
@ -96,9 +99,15 @@ class TopicScreenTest {
composeTestRule.setContent {
TopicScreen(
topicState = TopicUiState.Loading,
newsState = NewsUiState.Success(sampleNewsResources),
newsUiState = NewsUiState.Success(sampleNewsResources.mapIndexed { index, newsResource ->
SaveableNewsResource(
newsResource = newsResource,
isSaved = index % 2 == 0,
)
}),
onBackClick = { },
onFollowClick = { }
onFollowClick = { },
onBookmarkChanged = { _, _ -> },
)
}
@ -107,15 +116,22 @@ class TopicScreenTest {
.onNodeWithContentDescription(topicLoading)
.assertExists()
}
@Test
fun news_whenSuccessAndTopicIsSuccess_isShown() {
val testTopic = testTopics.first()
composeTestRule.setContent {
TopicScreen(
topicState = TopicUiState.Success(testTopic),
newsState = NewsUiState.Success(sampleNewsResources),
newsUiState = NewsUiState.Success(sampleNewsResources.mapIndexed { index, newsResource ->
SaveableNewsResource(
newsResource = newsResource,
isSaved = index % 2 == 0,
)
}),
onBackClick = { },
onFollowClick = { }
onFollowClick = { },
onBookmarkChanged = { _, _ -> },
)
}

Loading…
Cancel
Save