- Været i {arg.city}, {country}
+
+
+
+
{getWeatherIcon()}
+
+
+ {arg.city}
+
+
+ {country}
+
+
+
+
+
+
+
+
+
+ Temperatur
+
+
+ {temperature ? `${Math.round(temperature * 10) / 10}°C` : "N/A"}
+
+
+
+
+
+ Vind
+
+
+ {windSpeed ? `${Math.round(windSpeed * 10) / 10} m/s` : "N/A"}
+
+
+
+
+
+ Fuktighet
+
+
+ {humidity ? `${Math.round(humidity)}%` : "N/A"}
+
+
-
Temperatur: {temperature}°C
-
Vindhastighet: {windSpeed} m/s
-
)
}
diff --git a/tests/components/ViewCity.test.tsx b/tests/components/ViewCity.test.tsx
index 309134d..4937ef3 100644
--- a/tests/components/ViewCity.test.tsx
+++ b/tests/components/ViewCity.test.tsx
@@ -34,7 +34,11 @@ describe("ViewCity", () => {
{
data: {
instant: {
- details: { air_temperature: 12.5, wind_speed: 4.2 },
+ details: {
+ air_temperature: 12.5,
+ wind_speed: 4.2,
+ relative_humidity: 65.5,
+ },
},
},
},
@@ -43,11 +47,20 @@ describe("ViewCity", () => {
},
})
+ mockUseGetCityCoordinates.mockReturnValue({
+ result: [{ latitude: 59.9, longitude: 10.7, country: "Norway" }],
+ })
+
render(
)
- expect(screen.getByText("Været i Oslo,")).toBeTruthy()
- expect(screen.getByText("Temperatur: 12.5°C")).toBeTruthy()
- expect(screen.getByText("Vindhastighet: 4.2 m/s")).toBeTruthy()
+ expect(screen.getByText("Oslo")).toBeTruthy()
+ expect(screen.getByText("Norway")).toBeTruthy()
+ expect(screen.getByText("12.5°C")).toBeTruthy()
+ expect(screen.getByText("4.2 m/s")).toBeTruthy()
+ expect(screen.getByText("66%")).toBeTruthy()
+ expect(screen.getByText("Temperatur")).toBeTruthy()
+ expect(screen.getByText("Vind")).toBeTruthy()
+ expect(screen.getByText("Fuktighet")).toBeTruthy()
expect(mockUseGetCityCoordinates).toHaveBeenCalledWith({ cityName: "Oslo" })
expect(mockUseGetWeather).toHaveBeenCalledWith(59.9, 10.7)
})
@@ -57,7 +70,7 @@ describe("ViewCity", () => {
render(
)
- expect(screen.getByText("Laster")).toBeTruthy()
+ expect(screen.getByText("Laster...")).toBeTruthy()
})
it("should render an error message when the weather request fails", () => {