Merge pull request #2535 from rejas/issue_2530

This commit is contained in:
Michael Teeuw 2021-04-12 19:23:07 +02:00 committed by GitHub
commit fd952b88bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 8 deletions

View File

@ -26,6 +26,7 @@ _This release is scheduled to be released on 2021-04-01._
- Fix calendar start function logging inconsistency. - Fix calendar start function logging inconsistency.
- Fix updatenotification start function logging inconsistency. - Fix updatenotification start function logging inconsistency.
- Checks and applies the showDescription setting for the newsfeed module again - 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 - Fix decimalSymbol in the forcast part of the new weather module #2530
## [2.15.0] - 2021-04-01 ## [2.15.0] - 2021-04-01

View File

@ -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;
}

View File

@ -139,7 +139,7 @@ describe("Weather module", function () {
const weather = generateWeather(); const weather = generateWeather();
await setup({ template, data: weather }); 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 }); 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({ const weather = generateWeather({
main: { main: {
temp: (1.49 * 9) / 5 + 32, temp: (1.49 * 9) / 5 + 32,
@ -177,7 +177,7 @@ describe("Weather module", function () {
}); });
await setup({ template, data: weather }); 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"]; const days = ["Today", "Tomorrow", "Sun", "Mon", "Tue"];
for (const [index, day] of days.entries()) { 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"]; const icons = ["day-cloudy", "rain", "day-sunny", "day-sunny", "day-sunny"];
for (const [index, icon] of icons.entries()) { 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°"]; const temperatures = ["24.4°", "21.0°", "22.9°", "23.4°", "20.6°"];
for (const [index, temp] of temperatures.entries()) { 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°"]; const temperatures = ["15.3°", "13.6°", "13.8°", "13.9°", "10.9°"];
for (const [index, temp] of temperatures.entries()) { 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); 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);
}
});
});
}); });
}); });