Fix some eslint issues in the tests

This commit is contained in:
rejas 2021-07-01 16:37:27 +02:00 committed by veeck
parent bcff953fbb
commit 53720ae8ae
4 changed files with 72 additions and 68 deletions

View File

@ -5,7 +5,7 @@ describe("Clock set to spanish language module", function () {
let app = null; let app = null;
testMatch = async function (element, regex) { const testMatch = async function (element, regex) {
await app.client.waitUntilWindowLoaded(); await app.client.waitUntilWindowLoaded();
const elem = await app.client.$(element); const elem = await app.client.$(element);
const txt = await elem.getText(element); const txt = await elem.getText(element);

View File

@ -6,7 +6,7 @@ describe("Clock module", function () {
let app = null; let app = null;
testMatch = async function (element, regex) { const testMatch = async function (element, regex) {
await app.client.waitUntilWindowLoaded(); await app.client.waitUntilWindowLoaded();
const elem = await app.client.$(element); const elem = await app.client.$(element);
const txt = await elem.getText(element); const txt = await elem.getText(element);

View File

@ -4,39 +4,41 @@ const vm = require("vm");
const basedir = path.join(__dirname, "../../.."); const basedir = path.join(__dirname, "../../..");
beforeAll(function () {
const fileName = "js/app.js";
const filePath = path.join(basedir, fileName);
const code = fs.readFileSync(filePath);
sandbox = {
module: {},
__dirname: path.dirname(filePath),
global: {},
process: {
on: function () {},
env: {}
}
};
sandbox.require = function (filename) {
// This modifies the global slightly,
// but supplies vm with essential code
if (filename === "logger") {
return require("../mocks/logger.js");
} else {
try {
return require(filename);
} catch {
// ignore
}
}
};
vm.runInNewContext(code, sandbox, fileName);
});
describe("Default modules set in modules/default/defaultmodules.js", function () { describe("Default modules set in modules/default/defaultmodules.js", function () {
let sandbox = null;
beforeAll(function () {
const fileName = "js/app.js";
const filePath = path.join(basedir, fileName);
const code = fs.readFileSync(filePath);
sandbox = {
module: {},
__dirname: path.dirname(filePath),
global: {},
process: {
on: function () {},
env: {}
}
};
sandbox.require = function (filename) {
// This modifies the global slightly,
// but supplies vm with essential code
if (filename === "logger") {
return require("../mocks/logger.js");
} else {
try {
return require(filename);
} catch (ignore) {
// ignore
}
}
};
vm.runInNewContext(code, sandbox, fileName);
});
const expectedDefaultModules = require("../../../modules/default/defaultmodules"); const expectedDefaultModules = require("../../../modules/default/defaultmodules");
for (const defaultModule of expectedDefaultModules) { for (const defaultModule of expectedDefaultModules) {

View File

@ -2,41 +2,43 @@ const fs = require("fs");
const path = require("path"); const path = require("path");
const vm = require("vm"); const vm = require("vm");
beforeAll(function () {
const basedir = path.join(__dirname, "../../..");
const fileName = "js/app.js";
const filePath = path.join(basedir, fileName);
const code = fs.readFileSync(filePath);
sandbox = {
module: {},
__dirname: path.dirname(filePath),
global: {},
process: {
on: function () {},
env: {}
}
};
sandbox.require = function (filename) {
// This modifies the global slightly,
// but supplies vm with essential code
if (filename === "logger") {
return require("../mocks/logger.js");
} else {
try {
return require(filename);
} catch {
// ignore
}
}
};
vm.runInNewContext(code, sandbox, fileName);
});
describe("'global.root_path' set in js/app.js", function () { describe("'global.root_path' set in js/app.js", function () {
let sandbox = null;
beforeAll(function () {
const basedir = path.join(__dirname, "../../..");
const fileName = "js/app.js";
const filePath = path.join(basedir, fileName);
const code = fs.readFileSync(filePath);
sandbox = {
module: {},
__dirname: path.dirname(filePath),
global: {},
process: {
on: function () {},
env: {}
}
};
sandbox.require = function (filename) {
// This modifies the global slightly,
// but supplies vm with essential code
if (filename === "logger") {
return require("../mocks/logger.js");
} else {
try {
return require(filename);
} catch (ignore) {
// ignore
}
}
};
vm.runInNewContext(code, sandbox, fileName);
});
const expectedSubPaths = ["modules", "serveronly", "js", "js/app.js", "js/main.js", "js/electron.js", "config"]; const expectedSubPaths = ["modules", "serveronly", "js", "js/app.js", "js/main.js", "js/electron.js", "config"];
expectedSubPaths.forEach((subpath) => { expectedSubPaths.forEach((subpath) => {