mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 03:39:55 +00:00
refactor global-setup.js
This commit is contained in:
parent
0183d7a080
commit
6595b6a44f
@ -1,14 +1,13 @@
|
||||
const fetch = require("node-fetch");
|
||||
const helpers = require("./global-setup");
|
||||
let app = null;
|
||||
|
||||
describe("Electron app environment", function () {
|
||||
beforeAll(function (done) {
|
||||
app = helpers.startApplication("tests/configs/default.js");
|
||||
helpers.startApplication("tests/configs/default.js");
|
||||
helpers.getDocument(done);
|
||||
});
|
||||
afterAll(function () {
|
||||
helpers.stopApplication(app);
|
||||
helpers.stopApplication();
|
||||
});
|
||||
|
||||
it("get request from http://localhost:8080 should return 200", function (done) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
const fetch = require("node-fetch");
|
||||
const helpers = require("./global-setup");
|
||||
let app = null;
|
||||
|
||||
describe("All font files from roboto.css should be downloadable", function () {
|
||||
const fontFiles = [];
|
||||
@ -16,10 +15,10 @@ describe("All font files from roboto.css should be downloadable", function () {
|
||||
}
|
||||
|
||||
beforeAll(function () {
|
||||
app = helpers.startApplication("tests/configs/without_modules.js");
|
||||
helpers.startApplication("tests/configs/without_modules.js");
|
||||
});
|
||||
afterAll(function () {
|
||||
helpers.stopApplication(app);
|
||||
helpers.stopApplication();
|
||||
});
|
||||
|
||||
test.each(fontFiles)("should return 200 HTTP code for file '%s'", (fontFile, done) => {
|
||||
|
@ -3,22 +3,19 @@ const config = require("../configs/empty_ipWhiteList");
|
||||
|
||||
exports.startApplication = function (configFilename, exec) {
|
||||
jest.resetModules();
|
||||
let app = global.app;
|
||||
if (app) {
|
||||
app.stop();
|
||||
if (global.app) {
|
||||
global.app.stop();
|
||||
}
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = configFilename;
|
||||
if (exec) exec;
|
||||
app = require("app.js");
|
||||
app.start();
|
||||
global.app = app;
|
||||
return app;
|
||||
global.app = require("app.js");
|
||||
global.app.start();
|
||||
};
|
||||
|
||||
exports.stopApplication = function (app) {
|
||||
if (app) {
|
||||
app.stop();
|
||||
exports.stopApplication = function () {
|
||||
if (global.app) {
|
||||
global.app.stop();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
const fetch = require("node-fetch");
|
||||
const helpers = require("./global-setup");
|
||||
let app = null;
|
||||
|
||||
describe("ipWhitelist directive configuration", function () {
|
||||
describe("Set ipWhitelist without access", function () {
|
||||
beforeAll(function () {
|
||||
app = helpers.startApplication("tests/configs/noIpWhiteList.js");
|
||||
helpers.startApplication("tests/configs/noIpWhiteList.js");
|
||||
});
|
||||
afterAll(function () {
|
||||
helpers.stopApplication(app);
|
||||
helpers.stopApplication();
|
||||
});
|
||||
|
||||
it("should return 403", function (done) {
|
||||
@ -21,10 +20,10 @@ describe("ipWhitelist directive configuration", function () {
|
||||
|
||||
describe("Set ipWhitelist []", function () {
|
||||
beforeAll(function () {
|
||||
app = helpers.startApplication("tests/configs/empty_ipWhiteList.js");
|
||||
helpers.startApplication("tests/configs/empty_ipWhiteList.js");
|
||||
});
|
||||
afterAll(function () {
|
||||
helpers.stopApplication(app);
|
||||
helpers.stopApplication();
|
||||
});
|
||||
|
||||
it("should return 200", function (done) {
|
||||
|
@ -1,13 +1,12 @@
|
||||
const helpers = require("../global-setup");
|
||||
let app = null;
|
||||
|
||||
describe("Alert module", function () {
|
||||
beforeAll(function (done) {
|
||||
app = helpers.startApplication("tests/configs/modules/alert/default.js");
|
||||
helpers.startApplication("tests/configs/modules/alert/default.js");
|
||||
helpers.getDocument(done, 1000);
|
||||
});
|
||||
afterAll(function () {
|
||||
helpers.stopApplication(app);
|
||||
helpers.stopApplication();
|
||||
});
|
||||
|
||||
it("should show the welcome message", function () {
|
||||
|
@ -1,5 +1,4 @@
|
||||
const helpers = require("../global-setup");
|
||||
let app = null;
|
||||
|
||||
doTest = function (complimentsArray) {
|
||||
let elem = document.querySelector(".compliments");
|
||||
@ -11,12 +10,12 @@ doTest = function (complimentsArray) {
|
||||
|
||||
describe("Compliments module", function () {
|
||||
afterAll(function () {
|
||||
helpers.stopApplication(app);
|
||||
helpers.stopApplication();
|
||||
});
|
||||
|
||||
describe("parts of days", function () {
|
||||
beforeAll(function (done) {
|
||||
app = helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js");
|
||||
helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js");
|
||||
helpers.getDocument(done, 1000);
|
||||
});
|
||||
|
||||
@ -48,7 +47,7 @@ describe("Compliments module", function () {
|
||||
describe("Feature anytime in compliments module", function () {
|
||||
describe("Set anytime and empty compliments for morning, evening and afternoon ", function () {
|
||||
beforeAll(function (done) {
|
||||
app = helpers.startApplication("tests/configs/modules/compliments/compliments_anytime.js");
|
||||
helpers.startApplication("tests/configs/modules/compliments/compliments_anytime.js");
|
||||
helpers.getDocument(done, 1000);
|
||||
});
|
||||
|
||||
@ -59,7 +58,7 @@ describe("Compliments module", function () {
|
||||
|
||||
describe("Only anytime present in configuration compliments", function () {
|
||||
beforeAll(function (done) {
|
||||
app = helpers.startApplication("tests/configs/modules/compliments/compliments_only_anytime.js");
|
||||
helpers.startApplication("tests/configs/modules/compliments/compliments_only_anytime.js");
|
||||
helpers.getDocument(done, 1000);
|
||||
});
|
||||
|
||||
@ -72,7 +71,7 @@ describe("Compliments module", function () {
|
||||
describe("Feature date in compliments module", function () {
|
||||
describe("Set date and empty compliments for anytime, morning, evening and afternoon", function () {
|
||||
beforeAll(function (done) {
|
||||
app = helpers.startApplication("tests/configs/modules/compliments/compliments_date.js");
|
||||
helpers.startApplication("tests/configs/modules/compliments/compliments_date.js");
|
||||
helpers.getDocument(done, 1000);
|
||||
});
|
||||
|
@ -1,13 +1,12 @@
|
||||
const helpers = require("./global-setup");
|
||||
let app = null;
|
||||
|
||||
describe("Display of modules", function () {
|
||||
beforeAll(function (done) {
|
||||
app = helpers.startApplication("tests/configs/modules/display.js");
|
||||
helpers.startApplication("tests/configs/modules/display.js");
|
||||
helpers.getDocument(done);
|
||||
});
|
||||
afterAll(function () {
|
||||
helpers.stopApplication(app);
|
||||
helpers.stopApplication();
|
||||
});
|
||||
|
||||
it("should show the test header", function () {
|
||||
|
@ -1,13 +1,12 @@
|
||||
const helpers = require("./global-setup");
|
||||
let app = null;
|
||||
|
||||
describe("Position of modules", function () {
|
||||
beforeAll(function (done) {
|
||||
app = helpers.startApplication("tests/configs/modules/positions.js");
|
||||
helpers.startApplication("tests/configs/modules/positions.js");
|
||||
helpers.getDocument(done, 1000);
|
||||
});
|
||||
afterAll(function () {
|
||||
helpers.stopApplication(app);
|
||||
helpers.stopApplication();
|
||||
});
|
||||
|
||||
const positions = ["top_bar", "top_left", "top_center", "top_right", "upper_third", "middle_center", "lower_third", "bottom_left", "bottom_center", "bottom_right", "bottom_bar", "fullscreen_above", "fullscreen_below"];
|
||||
|
@ -1,14 +1,13 @@
|
||||
const fetch = require("node-fetch");
|
||||
const helpers = require("./global-setup");
|
||||
let app = null;
|
||||
|
||||
describe("port directive configuration", function () {
|
||||
describe("Set port 8090", function () {
|
||||
beforeAll(function () {
|
||||
app = helpers.startApplication("tests/configs/port_8090.js");
|
||||
helpers.startApplication("tests/configs/port_8090.js");
|
||||
});
|
||||
afterAll(function () {
|
||||
helpers.stopApplication(app);
|
||||
helpers.stopApplication();
|
||||
});
|
||||
|
||||
it("should return 200", function (done) {
|
||||
@ -21,10 +20,10 @@ describe("port directive configuration", function () {
|
||||
|
||||
describe("Set port 8100 on environment variable MM_PORT", function () {
|
||||
beforeAll(function () {
|
||||
app = helpers.startApplication("tests/configs/port_8090.js", (process.env.MM_PORT = 8100));
|
||||
helpers.startApplication("tests/configs/port_8090.js", (process.env.MM_PORT = 8100));
|
||||
});
|
||||
afterAll(function () {
|
||||
helpers.stopApplication(app);
|
||||
helpers.stopApplication();
|
||||
});
|
||||
|
||||
it("should return 200", function (done) {
|
||||
|
@ -1,13 +1,12 @@
|
||||
const fetch = require("node-fetch");
|
||||
const helpers = require("./global-setup");
|
||||
let app = null;
|
||||
|
||||
describe("Vendors", function () {
|
||||
beforeAll(function () {
|
||||
app = helpers.startApplication("tests/configs/default.js");
|
||||
helpers.startApplication("tests/configs/default.js");
|
||||
});
|
||||
afterAll(function () {
|
||||
helpers.stopApplication(app);
|
||||
helpers.stopApplication();
|
||||
});
|
||||
|
||||
describe("Get list vendors", function () {
|
||||
|
@ -1,13 +1,12 @@
|
||||
const helpers = require("./global-setup");
|
||||
let app = null;
|
||||
|
||||
describe("Check configuration without modules", function () {
|
||||
beforeAll(function (done) {
|
||||
app = helpers.startApplication("tests/configs/without_modules.js");
|
||||
helpers.startApplication("tests/configs/without_modules.js");
|
||||
helpers.getDocument(done, 1000);
|
||||
});
|
||||
afterAll(function () {
|
||||
helpers.stopApplication(app);
|
||||
helpers.stopApplication();
|
||||
});
|
||||
|
||||
it("Show the message MagicMirror title", function () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user