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