mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
@@ -13,7 +13,6 @@ exports.getText = async (element, result) => {
|
||||
};
|
||||
|
||||
exports.startApp = async (configFileName, additionalMockData) => {
|
||||
injectMockData(configFileName, additionalMockData);
|
||||
await helpers.startApplication("");
|
||||
await helpers.startApplication(injectMockData(configFileName, additionalMockData));
|
||||
await helpers.getDocument();
|
||||
};
|
||||
|
@@ -1,9 +1,11 @@
|
||||
const helpers = require("../helpers/global-setup");
|
||||
const weatherFunc = require("../helpers/weather-functions");
|
||||
const { cleanupMockData } = require("../../utils/weather_mocker");
|
||||
|
||||
describe("Weather module", () => {
|
||||
afterAll(async () => {
|
||||
await helpers.stopApplication();
|
||||
await cleanupMockData();
|
||||
});
|
||||
|
||||
describe("Current weather", () => {
|
||||
|
@@ -1,9 +1,11 @@
|
||||
const helpers = require("../helpers/global-setup");
|
||||
const weatherFunc = require("../helpers/weather-functions");
|
||||
const { cleanupMockData } = require("../../utils/weather_mocker");
|
||||
|
||||
describe("Weather module: Weather Forecast", () => {
|
||||
afterAll(async () => {
|
||||
await helpers.stopApplication();
|
||||
await cleanupMockData();
|
||||
});
|
||||
|
||||
describe("Default configuration", () => {
|
||||
|
@@ -1,9 +1,11 @@
|
||||
const helpers = require("../helpers/global-setup");
|
||||
const weatherFunc = require("../helpers/weather-functions");
|
||||
const { cleanupMockData } = require("../../utils/weather_mocker");
|
||||
|
||||
describe("Weather module: Weather Hourly Forecast", () => {
|
||||
afterAll(async () => {
|
||||
await helpers.stopApplication();
|
||||
await cleanupMockData();
|
||||
});
|
||||
|
||||
describe("Default configuration", () => {
|
||||
|
@@ -1,3 +1,4 @@
|
||||
const fs = require("fs");
|
||||
const helpers = require("./helpers/global-setup");
|
||||
|
||||
describe("templated config with port variable", () => {
|
||||
@@ -6,6 +7,11 @@ describe("templated config with port variable", () => {
|
||||
});
|
||||
afterAll(async () => {
|
||||
await helpers.stopApplication();
|
||||
try {
|
||||
fs.unlinkSync("tests/configs/port_variable.js");
|
||||
} catch (err) {
|
||||
// do nothing
|
||||
}
|
||||
});
|
||||
|
||||
it("should return 200", async () => {
|
||||
|
@@ -13,7 +13,6 @@ exports.getText = async (element, result) => {
|
||||
).toBe(result);
|
||||
};
|
||||
|
||||
exports.startApp = async (configFileNameName, systemDate) => {
|
||||
injectMockData(configFileNameName);
|
||||
await helpers.startApplication("", systemDate);
|
||||
exports.startApp = async (configFileName, systemDate) => {
|
||||
await helpers.startApplication(injectMockData(configFileName), systemDate);
|
||||
};
|
||||
|
@@ -1,9 +1,11 @@
|
||||
const helpers = require("../helpers/global-setup");
|
||||
const weatherHelper = require("../helpers/weather-setup");
|
||||
const { cleanupMockData } = require("../../utils/weather_mocker");
|
||||
|
||||
describe("Weather module", () => {
|
||||
afterEach(async () => {
|
||||
await helpers.stopApplication();
|
||||
await cleanupMockData();
|
||||
});
|
||||
|
||||
describe("Current weather with sunrise", () => {
|
||||
|
@@ -1,5 +1,7 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const util = require("util");
|
||||
const exec = util.promisify(require("child_process").exec);
|
||||
const _ = require("lodash");
|
||||
|
||||
/**
|
||||
@@ -35,9 +37,16 @@ const injectMockData = (configFileName, extendedData = {}) => {
|
||||
} else {
|
||||
mockWeather = readMockData("current", extendedData);
|
||||
}
|
||||
let content = fs.readFileSync(path.resolve(`${__dirname}../../../${configFileName}`)).toString();
|
||||
let content = fs.readFileSync(configFileName).toString();
|
||||
content = content.replace("#####WEATHERDATA#####", mockWeather);
|
||||
fs.writeFileSync(path.resolve(`${__dirname}../../../config/config.js`), content);
|
||||
const tempFile = configFileName.replace(".js", "_temp.js");
|
||||
fs.writeFileSync(tempFile, content);
|
||||
return tempFile;
|
||||
};
|
||||
|
||||
module.exports = { injectMockData };
|
||||
const cleanupMockData = async () => {
|
||||
const tempDir = path.resolve(`${__dirname}/../configs`).toString();
|
||||
await exec(`find ${tempDir} -type f -name *_temp.js -delete`);
|
||||
};
|
||||
|
||||
module.exports = { injectMockData, cleanupMockData };
|
||||
|
Reference in New Issue
Block a user