diff --git a/CHANGELOG.md b/CHANGELOG.md index 3627370c..d995e1b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ _This release is scheduled to be released on 2021-04-01._ - Fix calendar start function logging inconsistency. - Fix updatenotification start function logging inconsistency. - Checks and applies the showDescription setting for the newsfeed module again +- Fix tests in weather module and add one for decimalPoint in forecast - Fix decimalSymbol in the forcast part of the new weather module #2530 ## [2.15.0] - 2021-04-01 diff --git a/tests/configs/modules/weather/forecastweather_units.js b/tests/configs/modules/weather/forecastweather_units.js new file mode 100644 index 00000000..9d1a54ff --- /dev/null +++ b/tests/configs/modules/weather/forecastweather_units.js @@ -0,0 +1,39 @@ +/* Magic Mirror Test config default weather + * + * By rejas + * MIT Licensed. + */ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + + language: "en", + timeFormat: 24, + units: "imperial", + electronOptions: { + webPreferences: { + nodeIntegration: true, + enableRemoteModule: true + } + }, + + modules: [ + { + module: "weather", + position: "bottom_bar", + config: { + type: "forecast", + location: "Munich", + apiKey: "fake key", + weatherEndpoint: "/forecast/daily", + initialLoadDelay: 3000, + decimalSymbol: "_" + } + } + ] +}; + +/*************** DO NOT EDIT THE LINE BELOW ***************/ +if (typeof module !== "undefined") { + module.exports = config; +} diff --git a/tests/e2e/modules/weather_spec.js b/tests/e2e/modules/weather_spec.js index cd386f3c..70c88512 100644 --- a/tests/e2e/modules/weather_spec.js +++ b/tests/e2e/modules/weather_spec.js @@ -139,7 +139,7 @@ describe("Weather module", function () { const weather = generateWeather(); await setup({ template, data: weather }); - return getText(".weather .large.light span.bright", "1°C") && getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -6°C"); + return (await getText(".weather .large.light span.bright", "1°C")) && (await getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -6°C")); }); }); @@ -161,10 +161,10 @@ describe("Weather module", function () { }); await setup({ template, data: weather }); - return getText(".weather .normal.medium span:nth-child(2)", "6 WSW") && getText(".weather .large.light span.bright", "34,7°") && getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°"); + return (await getText(".weather .normal.medium span:nth-child(2)", "6 WSW")) && (await getText(".weather .large.light span.bright", "34,7°")) && getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°"); }); - it("should render decimalSymbol = ','", async function () { + it("should render custom decimalSymbol = ','", async function () { const weather = generateWeather({ main: { temp: (1.49 * 9) / 5 + 32, @@ -177,7 +177,7 @@ describe("Weather module", function () { }); await setup({ template, data: weather }); - return getText(".weather .normal.medium span:nth-child(3)", "93,7") && getText(".weather .large.light span.bright", "34,7°") && getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°"); + return (await getText(".weather .normal.medium span:nth-child(3)", "93,7")) && (await getText(".weather .large.light span.bright", "34,7°")) && getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°"); }); }); }); @@ -201,7 +201,7 @@ describe("Weather module", function () { const days = ["Today", "Tomorrow", "Sun", "Mon", "Tue"]; for (const [index, day] of days.entries()) { - getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day); + await getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day); } }); @@ -212,7 +212,7 @@ describe("Weather module", function () { const icons = ["day-cloudy", "rain", "day-sunny", "day-sunny", "day-sunny"]; for (const [index, icon] of icons.entries()) { - getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(2) span.wi-${icon}`); + await getElement(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(2) span.wi-${icon}`); } }); @@ -223,7 +223,7 @@ describe("Weather module", function () { const temperatures = ["24.4°", "21.0°", "22.9°", "23.4°", "20.6°"]; for (const [index, temp] of temperatures.entries()) { - getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp); + await getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp); } }); @@ -234,7 +234,7 @@ describe("Weather module", function () { const temperatures = ["15.3°", "13.6°", "13.8°", "13.9°", "10.9°"]; for (const [index, temp] of temperatures.entries()) { - getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp); + await getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp); } }); @@ -274,5 +274,22 @@ describe("Weather module", function () { expect(rows.length).to.be.equal(5); }); }); + + describe("Forecast weather units", function () { + before(function () { + process.env.MM_CONFIG_FILE = "tests/configs/modules/weather/forecastweather_units.js"; + }); + + it("should render custom decimalSymbol = '_'", async function () { + const weather = generateWeatherForecast(); + await setup({ template, data: weather }); + + const temperatures = ["24_4°", "21_0°", "22_9°", "23_4°", "20_6°"]; + + for (const [index, temp] of temperatures.entries()) { + await getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp); + } + }); + }); }); });