mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
Use metric units internally in all weatherproviders (#2849)
So finally I think this refactorin is ready to be reviewed :-) DONE: - [x] Removed all conversion functions for wind and temperature from specific weatherproviders - [x] Use internally only metric units: celsius for temperature, meters per seconds for wind - [x] Convert temp and wind into the configured units when displaying data on the UI - [x] look how beaufort calculation uses metrics, added knots as new windunit - [x] add more e2e tests Checked providers: - [x] Darksky - [x] EnvCanada - [x] OpenWeatherMap - [x] SMHI provider - [x] UK Met Office - [x] UK Met Office DataHub - [x] WeatherBit - [x] WeatherFlow - [x] WeatherGov TODO in different tickets: - check weatherproviders for usage of weatherEndpoint (as seen in https://github.com/MichMich/MagicMirror-Documentation/issues/131) -> see #2926 - cleanup precipations -> #2953 Co-authored-by: veeck <michael@veeck.de>
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
const moment = require("moment");
|
||||
const helpers = require("../helpers/global-setup");
|
||||
const weatherFunc = require("../helpers/weather-functions");
|
||||
|
||||
@@ -14,39 +13,15 @@ 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");
|
||||
});
|
||||
|
||||
it("should render temperature with icon", async () => {
|
||||
await weatherFunc.getText(".weather .large.light span.bright", "1.5°"); // now "1°C"
|
||||
await weatherFunc.getText(".weather .large.light span.bright", "1.5°");
|
||||
});
|
||||
|
||||
it("should render feels like temperature", async () => {
|
||||
await weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -5.6°"); // now "Feels like -6°C"
|
||||
});
|
||||
});
|
||||
|
||||
describe("Default configuration with sunrise", () => {
|
||||
beforeAll(async () => {
|
||||
const sunrise = moment().startOf("day").unix();
|
||||
const sunset = moment().startOf("day").unix();
|
||||
await weatherFunc.startApp("tests/configs/modules/weather/currentweather_default.js", { sys: { sunrise, sunset } });
|
||||
});
|
||||
|
||||
it("should render sunrise", async () => {
|
||||
await weatherFunc.getText(".weather .normal.medium span:nth-child(4)", "12:00 am");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Default configuration with sunset", () => {
|
||||
beforeAll(async () => {
|
||||
const sunrise = moment().startOf("day").unix();
|
||||
const sunset = moment().endOf("day").unix();
|
||||
await weatherFunc.startApp("tests/configs/modules/weather/currentweather_default.js", { sys: { sunrise, sunset } });
|
||||
});
|
||||
|
||||
it("should render sunset", async () => {
|
||||
await weatherFunc.getText(".weather .normal.medium span:nth-child(4)", "11:59 pm");
|
||||
await weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -5.6°");
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -66,65 +41,44 @@ describe("Weather module", () => {
|
||||
await weatherFunc.startApp("tests/configs/modules/weather/currentweather_options.js", {});
|
||||
});
|
||||
|
||||
it("should render useBeaufort = false", async () => {
|
||||
await weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "12");
|
||||
it("should render windUnits in beaufort", async () => {
|
||||
await weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "6");
|
||||
});
|
||||
|
||||
it("should render showWindDirectionAsArrow = true", async () => {
|
||||
it("should render windDirection with an arrow", async () => {
|
||||
const elem = await helpers.waitForElement(".weather .normal.medium sup i.fa-long-arrow-alt-up");
|
||||
expect(elem).not.toBe(null);
|
||||
expect(elem.outerHTML).toContain("transform:rotate(250deg);");
|
||||
});
|
||||
|
||||
it("should render showHumidity = true", async () => {
|
||||
it("should render humidity", async () => {
|
||||
await weatherFunc.getText(".weather .normal.medium span:nth-child(3)", "93.7");
|
||||
});
|
||||
|
||||
it("should render degreeLabel = true for temp", async () => {
|
||||
it("should render degreeLabel for temp", async () => {
|
||||
await weatherFunc.getText(".weather .large.light span.bright", "1°C");
|
||||
});
|
||||
|
||||
it("should render degreeLabel = true for feels like", async () => {
|
||||
it("should render degreeLabel for feels like", async () => {
|
||||
await weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -6°C");
|
||||
});
|
||||
});
|
||||
|
||||
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");
|
||||
it("should render wind in imperial units", async () => {
|
||||
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°");
|
||||
});
|
||||
|
||||
it("should render custom decimalSymbol = ',' for humidity", async () => {
|
||||
await weatherFunc.getText(".weather .normal.medium span:nth-child(3)", "93,7");
|
||||
});
|
||||
|
||||
it("should render custom decimalSymbol = ',' for temp", async () => {
|
||||
await weatherFunc.getText(".weather .large.light span.bright", "34,7°");
|
||||
});
|
||||
|
||||
it("should render custom decimalSymbol = ',' for feels like", async () => {
|
||||
await weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°");
|
||||
it("should render 'feels like' in fahrenheit", async () => {
|
||||
await weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 21,9°");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user