change getDocument, delay needed, now 2 tests moved

This commit is contained in:
Karsten Hassel
2021-09-24 23:39:12 +02:00
parent a1c7f20990
commit c0ce52abe3
8 changed files with 57 additions and 96 deletions

View File

@@ -1,7 +1,7 @@
const jsdom = require("jsdom");
const config = require("../configs/empty_ipWhiteList");
exports.startApplication = function (configFilename, exec, callback) {
exports.startApplication = function (configFilename, exec) {
jest.resetModules();
// Set config sample for use in test
process.env.MM_CONFIG_FILE = configFilename;
@@ -9,16 +9,6 @@ exports.startApplication = function (configFilename, exec, callback) {
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;
};
@@ -27,3 +17,15 @@ exports.stopApplication = function (app) {
app.stop();
}
};
exports.getDocument = function (callback, ms) {
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;
setTimeout(() => {
callback();
}, ms);
};
});
};