Change-Id: I1bce9ac7534f376a9626cac2c50e1bcc7620cf61pull/476/head
parent
f563862df3
commit
3712ba8c2f
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.samples.apps.nowinandroid.core.ui
|
||||
|
||||
import androidx.compose.ui.test.assertIsDisplayed
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
class NewsResourceCardTest {
|
||||
@get:Rule
|
||||
val composeTestRule = createComposeRule()
|
||||
|
||||
@Test
|
||||
fun testMetaDataDisplay() {
|
||||
// Resource with known resource type
|
||||
val newsResource = previewNewsResources[0]
|
||||
var dateFormatted = ""
|
||||
|
||||
composeTestRule.setContent {
|
||||
NewsResourceCardExpanded(
|
||||
newsResource = newsResource,
|
||||
isBookmarked = false,
|
||||
onToggleBookmark = {},
|
||||
onClick = {}
|
||||
)
|
||||
|
||||
dateFormatted = dateFormatted(publishDate = newsResource.publishDate)
|
||||
}
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithText(dateFormatted + " • " + newsResource.type.displayText)
|
||||
.assertIsDisplayed()
|
||||
|
||||
// Resource with Unknown resource type
|
||||
val newsResource2 = previewNewsResources[4]
|
||||
|
||||
composeTestRule.setContent {
|
||||
NewsResourceCardExpanded(
|
||||
newsResource = newsResource2,
|
||||
isBookmarked = false,
|
||||
onToggleBookmark = {},
|
||||
onClick = {}
|
||||
)
|
||||
|
||||
dateFormatted = dateFormatted(publishDate = newsResource.publishDate)
|
||||
}
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithText(dateFormatted)
|
||||
.assertIsDisplayed()
|
||||
}
|
||||
}
|
Loading…
Reference in new issue