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