MagicMirror/tests/unit/global_vars/root_path_spec.js

29 lines
953 B
JavaScript
Raw Normal View History

2020-04-19 08:18:11 +02:00
const fs = require("fs");
const path = require("path");
2017-01-24 12:22:43 +01:00
const root_path = path.join(__dirname, "../../..");
const version = require(`${__dirname}/../../../package.json`).version;
2017-01-25 22:42:04 +01:00
describe("'global.root_path' set in js/app.js", () => {
2021-04-08 21:12:56 +02:00
const expectedSubPaths = ["modules", "serveronly", "js", "js/app.js", "js/main.js", "js/electron.js", "config"];
2017-01-24 12:22:43 +01:00
expectedSubPaths.forEach((subpath) => {
it(`contains a file/folder "${subpath}"`, () => {
expect(fs.existsSync(path.join(root_path, subpath))).toBe(true);
2017-01-24 12:22:43 +01:00
});
});
2017-01-25 22:42:04 +01:00
it("should not modify global.root_path for testing", () => {
expect(global.root_path).toBeUndefined();
2017-01-25 22:42:04 +01:00
});
it("should not modify global.version for testing", () => {
expect(global.version).toBeUndefined();
2017-01-25 22:42:04 +01:00
});
2017-02-07 19:35:51 -03:00
it("should expect the global.version equals package.json file", () => {
const versionPackage = JSON.parse(fs.readFileSync("package.json", "utf8")).version;
expect(version).toBe(versionPackage);
2017-02-07 19:35:51 -03:00
});
2017-01-24 12:22:43 +01:00
});