Skip to content

Commit abbfa09

Browse files
committed
create test WeatherInfoKtTest.kt
1 parent 1bf9156 commit abbfa09

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import androidx.compose.ui.test.junit4.createComposeRule
2+
import androidx.compose.ui.test.onNodeWithText
3+
import androidx.compose.ui.test.assertIsDisplayed
4+
import com.rishirajput.domain.model.WeatherData
5+
import com.rishirajput.weather.presentation.ui.compose.WeatherInfo
6+
import org.junit.Rule
7+
import org.junit.Test
8+
9+
class WeatherInfoTest {
10+
11+
@get:Rule
12+
val composeTestRule = createComposeRule()
13+
14+
@Test
15+
fun weatherInfo_displaysCorrectData() {
16+
val dummyWeatherData = WeatherData(
17+
locationName = "Hyderabad",
18+
temperature = 31.0,
19+
condition = "Patchy rain nearby",
20+
icon = "//cdn.weatherapi.com/weather/64x64/night/176.png",
21+
humidity = 76,
22+
uvIndex = 4.0,
23+
feelsLike = 30.4
24+
)
25+
26+
composeTestRule.setContent {
27+
WeatherInfo(weatherData = dummyWeatherData)
28+
}
29+
30+
composeTestRule.onNodeWithText("Humidity").assertIsDisplayed()
31+
composeTestRule.onNodeWithText("76%").assertIsDisplayed()
32+
composeTestRule.onNodeWithText("UV").assertIsDisplayed()
33+
composeTestRule.onNodeWithText("4.0").assertIsDisplayed()
34+
composeTestRule.onNodeWithText("Feels Like").assertIsDisplayed()
35+
composeTestRule.onNodeWithText("30.4°").assertIsDisplayed()
36+
}
37+
}

0 commit comments

Comments
 (0)