Skip to content

Commit

Permalink
Fix weather tests
Browse files Browse the repository at this point in the history
  • Loading branch information
veeck committed Oct 19, 2022
1 parent a9fecbe commit 0ae9bdb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
2 changes: 1 addition & 1 deletion modules/default/weather/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ Module.register("weather", {
* @returns {number}
*/
convertTemp(tempInC) {
return this.config.tempUnits === "imperial" ? tempInC * 1.8 + 32 : tempInC;
return this.config.tempUnits === "imperial" ? this.roundValue(tempInC * 1.8 + 32) : tempInC;
},

convertWind(windInMS) {
Expand Down
23 changes: 7 additions & 16 deletions tests/e2e/modules/weather_current_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("Weather module", () => {
});

it("should render wind speed and wind direction", async () => {
await weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "6 WSW"); // now "12"
await weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "12 WSW"); // now "12"
});

it("should render temperature with icon", async () => {
Expand Down Expand Up @@ -89,30 +89,21 @@ describe("Weather module", () => {
});
});

describe("Current weather units", () => {
describe("Current weather with imperial units", () => {
beforeAll(async () => {
await weatherFunc.startApp("tests/configs/modules/weather/currentweather_units.js", {
main: {
temp: (1.49 * 9) / 5 + 32,
temp_min: (1 * 9) / 5 + 32,
temp_max: (2 * 9) / 5 + 32
},
wind: {
speed: 11.8 * 2.23694
}
});
await weatherFunc.startApp("tests/configs/modules/weather/currentweather_units.js", {});
});

it("should render imperial units for wind", async () => {
await weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "6 WSW");
await weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "26 WSW");
});

it("should render imperial units for temp", async () => {
it("should render temperatures in fahrenheit", async () => {
await weatherFunc.getText(".weather .large.light span.bright", "34,7°");
});

it("should render imperial units for feels like", async () => {
await weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°");
await weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 21,9°");
});

it("should render custom decimalSymbol = ',' for humidity", async () => {
Expand All @@ -124,7 +115,7 @@ describe("Weather module", () => {
});

it("should render custom decimalSymbol = ',' for feels like", async () => {
await weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°");
await weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 21,9°");
});
});
});
2 changes: 1 addition & 1 deletion tests/e2e/modules/weather_forecast_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe("Weather module: Weather Forecast", () => {
await weatherFunc.startApp("tests/configs/modules/weather/forecastweather_units.js", {});
});

const temperatures = ["24_4°", "21_0°", "22_9°", "23_4°", "20_6°"];
const temperatures = ["75_9°", "69_8°", "73_2°", "74_1°", "69_1°"];
for (const [index, temp] of temperatures.entries()) {
it("should render custom decimalSymbol = '_' for temp " + temp, async () => {
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp);
Expand Down

0 comments on commit 0ae9bdb

Please sign in to comment.