mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 03:39:55 +00:00
Adds new config option to show weather forecast for every X hour (default value is 1 which reflects the current behaviour) Also adds tests for hourly forecast Fixes #2996 Co-authored-by: veeck <michael@veeck.de>
32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
const helpers = require("./global-setup");
|
|
const path = require("path");
|
|
const fs = require("fs");
|
|
const { generateWeather, generateWeatherForecast, generateWeatherHourly } = require("../../mocks/weather_test");
|
|
|
|
exports.getText = async (element, result) => {
|
|
const elem = await helpers.waitForElement(element);
|
|
expect(elem).not.toBe(null);
|
|
expect(
|
|
elem.textContent
|
|
.trim()
|
|
.replace(/(\r\n|\n|\r)/gm, "")
|
|
.replace(/[ ]+/g, " ")
|
|
).toBe(result);
|
|
};
|
|
|
|
exports.startApp = async (configFile, additionalMockData) => {
|
|
let mockWeather;
|
|
if (configFile.includes("forecast")) {
|
|
mockWeather = generateWeatherForecast(additionalMockData);
|
|
} else if (configFile.includes("hourly")) {
|
|
mockWeather = generateWeatherHourly(additionalMockData);
|
|
} else {
|
|
mockWeather = generateWeather(additionalMockData);
|
|
}
|
|
let content = fs.readFileSync(path.resolve(__dirname + "../../../../" + configFile)).toString();
|
|
content = content.replace("#####WEATHERDATA#####", mockWeather);
|
|
fs.writeFileSync(path.resolve(__dirname + "../../../../config/config.js"), content);
|
|
await helpers.startApplication("");
|
|
await helpers.getDocument();
|
|
};
|