mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
unit tests
This commit is contained in:
@@ -5,12 +5,12 @@ const vm = require("vm");
|
||||
|
||||
const basedir = path.join(__dirname, "../../..");
|
||||
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
const fileName = "js/app.js";
|
||||
const filePath = path.join(basedir, fileName);
|
||||
const code = fs.readFileSync(filePath);
|
||||
|
||||
this.sandbox = {
|
||||
sandbox = {
|
||||
module: {},
|
||||
__dirname: path.dirname(filePath),
|
||||
global: {},
|
||||
@@ -27,13 +27,13 @@ before(function () {
|
||||
}
|
||||
};
|
||||
|
||||
this.sandbox.require = function (filename) {
|
||||
sandbox.require = function (filename) {
|
||||
// This modifies the global slightly,
|
||||
// but supplies vm with essential code
|
||||
return require(filename);
|
||||
};
|
||||
|
||||
vm.runInNewContext(code, this.sandbox, fileName);
|
||||
vm.runInNewContext(code, sandbox, fileName);
|
||||
});
|
||||
|
||||
describe("Default modules set in modules/default/defaultmodules.js", function () {
|
||||
@@ -41,7 +41,7 @@ describe("Default modules set in modules/default/defaultmodules.js", function ()
|
||||
|
||||
for (const defaultModule of expectedDefaultModules) {
|
||||
it(`contains a folder for modules/default/${defaultModule}"`, function () {
|
||||
expect(fs.existsSync(path.join(this.sandbox.global.root_path, "modules/default", defaultModule))).to.equal(true);
|
||||
expect(fs.existsSync(path.join(sandbox.global.root_path, "modules/default", defaultModule))).to.equal(true);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user