fix logger.js, move jsdom in startApplication

This commit is contained in:
Karsten Hassel
2021-09-24 21:30:51 +02:00
parent 0ef6f89d44
commit a1c7f20990
4 changed files with 27 additions and 16 deletions

View File

@@ -1,6 +1,7 @@
const jsdom = require("jsdom");
const config = require("../configs/empty_ipWhiteList");
exports.startApplication = function (configFilename, exec) {
exports.startApplication = function (configFilename, exec, callback) {
jest.resetModules();
// Set config sample for use in test
process.env.MM_CONFIG_FILE = configFilename;
@@ -8,6 +9,16 @@ exports.startApplication = function (configFilename, exec) {
const app = require("app.js");
app.start();
if (callback) {
const url = "http://" + (config.address || "localhost") + ":" + (config.port || "8080");
jsdom.JSDOM.fromURL(url, { resources: "usable", runScripts: "dangerously" }).then((dom) => {
dom.window.onload = function () {
global.document = dom.window.document;
callback();
};
});
};
return app;
};
@@ -16,12 +27,3 @@ exports.stopApplication = function (app) {
app.stop();
}
};
exports.getDocument = function (url, callback) {
jsdom.JSDOM.fromURL(url, { resources: "usable", runScripts: "dangerously" }).then((dom) => {
dom.window.onload = function () {
global.document = dom.window.document;
callback();
};
});
};