Skip to content

Commit

Permalink
Rename ForecastCard to DailyForecastCard
Browse files Browse the repository at this point in the history
I'm planning on adding hourly forecasts later.
  • Loading branch information
tobyhs committed Sep 11, 2024
1 parent 43b77e6 commit 058e675
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import java.util.Locale
*/
@OptIn(ExperimentalLayoutApi::class)
@Composable
fun ForecastCard(forecast: DailyForecast) {
fun DailyForecastCard(forecast: DailyForecast) {
val locale = Locale.getDefault()

Card(Modifier.fillMaxWidth().padding(dimensionResource(R.dimen.forecast_card_padding))) {
Expand Down Expand Up @@ -92,7 +92,7 @@ fun ForecastCard(forecast: DailyForecast) {

internal val DATE_FORMATTER: DateTimeFormatter = DateTimeFormatter.ofPattern("MMM d")

internal val previewDataForecasts = listOf(
internal val previewDataDailyForecasts = listOf(
DailyForecast(
date = LocalDate.parse("2023-01-15"),
low = 45,
Expand Down Expand Up @@ -132,6 +132,6 @@ internal val previewDataForecasts = listOf(

@Preview
@Composable
private fun ForecastCardPreview() {
ForecastCard(previewDataForecasts[0])
private fun DailyForecastCardPreview() {
DailyForecastCard(previewDataDailyForecasts[0])
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fun ForecastScreenContent(forecastResultSet: ForecastResultSet) {

Column(Modifier.verticalScroll(rememberScrollState())) {
for (forecast in forecastResultSet.dailyForecasts) {
ForecastCard(forecast)
DailyForecastCard(forecast)
}
}
}
Expand All @@ -40,7 +40,7 @@ fun ForecastScreenContent(forecastResultSet: ForecastResultSet) {
internal val previewDataForecastResultSet = ForecastResultSet(
location = "Some City, ST",
publicationTime = ZonedDateTime.of(2023, 1, 15, 12, 30, 0, 0, ZoneId.systemDefault()),
dailyForecasts = previewDataForecasts,
dailyForecasts = previewDataDailyForecasts,
)

@Preview
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class ForecastCardTest {
class DailyForecastCardTest {
@get:Rule val composeRule = createComposeRule()

@Test
fun compose() {
composeRule.setContent {
ForecastCard(ForecastResultSetFactory.createDailyForecasts()[0])
DailyForecastCard(ForecastResultSetFactory.createDailyForecasts()[0])
}

checkContent(composeRule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ForecastScreenContentTest {
composeRule.onNodeWithTag("publicationTime")
.assertTextEquals("Fri, 1 Feb 2019 12:00:00 GMT")

ForecastCardTest.checkContent(composeRule)
DailyForecastCardTest.checkContent(composeRule)
composeRule.onAllNodesWithTag("dayOfWeek")[1].assertTextEquals("Sat")
composeRule.onAllNodesWithTag("date")[1].assertTextEquals("Feb 2")
composeRule.onAllNodesWithTag("lowTemperature")[1].assertTextEquals("58")
Expand Down

0 comments on commit 058e675

Please sign in to comment.