Merge branch 'develop' into feature/automated-weather-tests

# Conflicts:
#	modules/default/weather/weather.js
#	package-lock.json
#	package.json
This commit is contained in:
fewieden
2019-09-11 13:07:31 +02:00
121 changed files with 6959 additions and 4195 deletions

View File

@@ -16,7 +16,7 @@ var Utils = require(__dirname + "/../../js/utils.js");
/* getConfigFile()
* Return string with path of configuration file
* Check if set by enviroment variable MM_CONFIG_FILE
* Check if set by environment variable MM_CONFIG_FILE
*/
function getConfigFile() {
// FIXME: This function should be in core. Do you want refactor me ;) ?, be good!
@@ -35,7 +35,7 @@ function checkConfigFile() {
console.error(Utils.colors.error("File not found: "), configFileName);
return;
}
// check permision
// check permission
try {
fs.accessSync(configFileName, fs.F_OK);
} catch (e) {
@@ -52,12 +52,12 @@ function checkConfigFile() {
if (err) { throw err; }
v.JSHINT(data); // Parser by jshint
if (v.JSHINT.errors.length == 0) {
if (v.JSHINT.errors.length === 0) {
console.log("Your configuration file doesn't contain syntax errors :)");
return true;
} else {
errors = v.JSHINT.data().errors;
for (idx in errors) {
for (var idx in errors) {
error = errors[idx];
console.log("Line", error.line, "col", error.character, error.reason);
}
@@ -67,4 +67,4 @@ function checkConfigFile() {
if (process.env.NODE_ENV !== "test") {
checkConfigFile();
};
}

View File

@@ -1,4 +1,4 @@
/* Magic Mirror Test config sample enviroment
/* Magic Mirror Test config sample environment
*
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
* MIT Licensed.

View File

@@ -6,7 +6,6 @@
* MIT Licensed.
*/
var config = {
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],

View File

@@ -1,4 +1,4 @@
/* Magic Mirror Test config sample enviroment set por 8090
/* Magic Mirror Test config sample environment set port 8090
*
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
* MIT Licensed.

View File

@@ -1,13 +1,8 @@
const helpers = require("./global-setup");
const path = require("path");
const request = require("request");
const expect = require("chai").expect;
const describe = global.describe;
const it = global.it;
const beforeEach = global.beforeEach;
const afterEach = global.afterEach;
describe("Development console tests", function() {
// This tests fail and crash another tests

View File

@@ -1,7 +1,5 @@
const helpers = require("./global-setup");
const path = require("path");
const request = require("request");
const expect = require("chai").expect;
const describe = global.describe;

View File

@@ -1,14 +1,9 @@
const helpers = require("./global-setup");
const path = require("path");
const request = require("request");
const expect = require("chai").expect;
const forEach = require("mocha-each");
const describe = global.describe;
const it = global.it;
const beforeEach = global.beforeEach;
const afterEach = global.afterEach;
const forEach = require("mocha-each");
describe("All font files from roboto.css should be downloadable", function() {
helpers.setupTimeout(this);
@@ -18,7 +13,7 @@ describe("All font files from roboto.css should be downloadable", function() {
var fileContent = require("fs").readFileSync(__dirname + "/../../fonts/roboto.css", "utf8");
var regex = /\burl\(['"]([^'"]+)['"]\)/g;
var match = regex.exec(fileContent);
while (match != null) {
while (match !== null) {
// Push 1st match group onto fontFiles stack
fontFiles.push(match[1]);
// Find the next one

View File

@@ -12,7 +12,6 @@ const Application = require("spectron").Application;
const assert = require("assert");
const chai = require("chai");
const chaiAsPromised = require("chai-as-promised");
const path = require("path");
global.before(function() {

View File

@@ -1,7 +1,5 @@
const helpers = require("./global-setup");
const path = require("path");
const request = require("request");
const expect = require("chai").expect;
const describe = global.describe;
@@ -17,7 +15,7 @@ describe("ipWhitelist directive configuration", function () {
beforeEach(function () {
return helpers.startApplication({
args: ["js/electron.js"]
}).then(function (startedApp) { app = startedApp; })
}).then(function (startedApp) { app = startedApp; });
});
afterEach(function () {

View File

@@ -1,10 +1,6 @@
const helpers = require("../global-setup");
const path = require("path");
const request = require("request");
const serverBasicAuth = require("../../servers/basic-auth.js");
const expect = require("chai").expect;
const describe = global.describe;
const it = global.it;
const beforeEach = global.beforeEach;
@@ -72,7 +68,7 @@ describe("Calendar module", function() {
});
});
describe("Basic auth backward compatibilty configuration: DEPRECATED", function() {
describe("Basic auth backward compatibility configuration: DEPRECATED", function() {
before(function() {
serverBasicAuth.listen(8012);
// Set config sample for use in test

View File

@@ -1,8 +1,4 @@
const helpers = require("../global-setup");
const path = require("path");
const request = require("request");
const expect = require("chai").expect;
const describe = global.describe;
const it = global.it;
@@ -86,5 +82,4 @@ describe("Clock set to spanish language module", function() {
.getText(".clock .week").should.eventually.match(weekRegex);
});
});
});

View File

@@ -1,8 +1,4 @@
const helpers = require("../global-setup");
const path = require("path");
const request = require("request");
const expect = require("chai").expect;
const describe = global.describe;
const it = global.it;

View File

@@ -1,7 +1,4 @@
const helpers = require("../global-setup");
const path = require("path");
const request = require("request");
const expect = require("chai").expect;
const describe = global.describe;

View File

@@ -1,8 +1,4 @@
const helpers = require("../global-setup");
const path = require("path");
const request = require("request");
const expect = require("chai").expect;
const describe = global.describe;
const it = global.it;
@@ -24,7 +20,6 @@ describe("Test helloworld module", function() {
});
});
afterEach(function() {
return helpers.stopApplication(app);
});
@@ -52,5 +47,4 @@ describe("Test helloworld module", function() {
.getText(".helloworld").should.eventually.equal("Hello World!");
});
});
});

View File

@@ -1,8 +1,4 @@
const helpers = require("../global-setup");
const path = require("path");
const request = require("request");
const expect = require("chai").expect;
const describe = global.describe;
const it = global.it;

View File

@@ -1,13 +1,7 @@
const helpers = require("./global-setup");
const path = require("path");
const request = require("request");
const expect = require("chai").expect;
const describe = global.describe;
const it = global.it;
const beforeEach = global.beforeEach;
const afterEach = global.afterEach;
describe("Position of modules", function () {
helpers.setupTimeout(this);
@@ -25,8 +19,7 @@ describe("Position of modules", function () {
process.env.MM_CONFIG_FILE = "tests/configs/modules/positions.js";
return helpers.startApplication({
args: ["js/electron.js"]
}).then(function (startedApp) { app = startedApp; })
}).then(function (startedApp) { app = startedApp; });
});
var positions = ["top_bar", "top_left", "top_center", "top_right", "upper_third",
@@ -44,5 +37,4 @@ describe("Position of modules", function () {
});
}
});
});

View File

@@ -1,7 +1,5 @@
const helpers = require("./global-setup");
const path = require("path");
const request = require("request");
const expect = require("chai").expect;
const describe = global.describe;
@@ -17,7 +15,7 @@ describe("port directive configuration", function () {
beforeEach(function () {
return helpers.startApplication({
args: ["js/electron.js"]
}).then(function (startedApp) { app = startedApp; })
}).then(function (startedApp) { app = startedApp; });
});
afterEach(function () {
@@ -38,7 +36,7 @@ describe("port directive configuration", function () {
});
});
describe("Set port 8100 on enviroment variable MM_PORT", function () {
describe("Set port 8100 on environment variable MM_PORT", function () {
before(function () {
process.env.MM_PORT = 8100;
// Set config sample for use in this test
@@ -56,5 +54,4 @@ describe("port directive configuration", function () {
});
});
});
});

View File

@@ -121,8 +121,7 @@ describe("Translations", function() {
throw e;
}
}
})
});
});
}
});

View File

@@ -1,7 +1,5 @@
const helpers = require("./global-setup");
const path = require("path");
const request = require("request");
const expect = require("chai").expect;
const describe = global.describe;
@@ -11,7 +9,6 @@ const after = global.after;
describe("Vendors", function () {
return; // Test still getting failed in Travis
helpers.setupTimeout(this);
@@ -20,7 +17,7 @@ describe("Vendors", function () {
before(function () {
return helpers.startApplication({
args: ["js/electron.js"]
}).then(function (startedApp) { app = startedApp; })
}).then(function (startedApp) { app = startedApp; });
});
after(function () {
@@ -42,5 +39,14 @@ describe("Vendors", function () {
});
});
});
Object.keys(vendors).forEach(vendor => {
it(`should return 404 HTTP code for vendor https://localhost/"${vendor}"`, function() {
urlVendor = "http://localhost:8080/" + vendors[vendor];
request.get(urlVendor, function (err, res, body) {
expect(res.statusCode).to.equal(404);
});
});
});
});
});

View File

@@ -1,8 +1,4 @@
const helpers = require("./global-setup");
const path = require("path");
const request = require("request");
const expect = require("chai").expect;
const describe = global.describe;
const it = global.it;
@@ -17,7 +13,7 @@ describe("Check configuration without modules", function () {
beforeEach(function () {
return helpers.startApplication({
args: ["js/electron.js"]
}).then(function (startedApp) { app = startedApp; })
}).then(function (startedApp) { app = startedApp; });
});
afterEach(function () {
@@ -31,13 +27,12 @@ describe("Check configuration without modules", function () {
it("Show the message MagicMirror title", function () {
return app.client.waitUntilWindowLoaded()
.getText("#module_1_helloworld .module-content").should.eventually.equal("Magic Mirror2")
.getText("#module_1_helloworld .module-content").should.eventually.equal("Magic Mirror2");
});
it("Show the text Michael's website", function () {
return app.client.waitUntilWindowLoaded()
.getText("#module_5_helloworld .module-content").should.eventually.equal("www.michaelteeuw.nl");
});
});

View File

@@ -1,4 +1,3 @@
var http = require("http");
var path = require("path");
var auth = require("http-auth");
var express = require("express");
@@ -17,11 +16,11 @@ var basic = auth.basic(
app.use(auth.connect(basic));
// Set directories availables
// Set available directories
var directories = ["/tests/configs"];
var directory;
rootPath = path.resolve(__dirname + "/../../");
for (i in directories) {
for (var i in directories) {
directory = directories[i];
app.use(directory, express.static(path.resolve(rootPath + directory)));
}

View File

@@ -1,5 +1,4 @@
const chai = require("chai");
const expect = chai.expect;
const expect = require("chai").expect;
const path = require("path");
const {JSDOM} = require("jsdom");

View File

@@ -1,5 +1,4 @@
const chai = require("chai");
const expect = chai.expect;
const expect = require("chai").expect;
const deprecated = require("../../../js/deprecated");
describe("Deprecated", function() {

View File

@@ -1,7 +1,5 @@
const chai = require("chai");
const expect = chai.expect;
const expect = require("chai").expect;
const path = require("path");
const fs = require("fs");
const helmet = require("helmet");
const {JSDOM} = require("jsdom");
const express = require("express");

View File

@@ -1,5 +1,4 @@
var chai = require("chai");
var expect = chai.expect;
var expect = require("chai").expect;
var Utils = require("../../../js/utils.js");
var colors = require("colors/safe");
@@ -38,4 +37,3 @@ describe("Utils", function() {
});
});
});

View File

@@ -5,7 +5,7 @@ global.moment = require("moment");
describe("Functions into modules/default/calendar/calendar.js", function() {
// Fake for use by calendar.js
Module = {}
Module = {};
Module.definitions = {};
Module.register = function (name, moduleDefinition) {
Module.definitions[name] = moduleDefinition;

View File

@@ -1,5 +1,4 @@
const chai = require("chai");
const expect = chai.expect;
const expect = require("chai").expect;
const path = require("path");
const {JSDOM} = require("jsdom");
@@ -29,4 +28,3 @@ describe("Test function cmpVersions in js/module.js", function() {
expect(cmp("1.1", "1.0")).to.equal(1);
});
});

View File

@@ -1,13 +1,7 @@
var fs = require("fs");
var path = require("path");
var chai = require("chai");
var expect = chai.expect;
var vm = require("vm");
var expect = require("chai").expect;
describe("Functions module currentweather", function() {
// Fake for use by currentweather.js
Module = {};
config = {};
@@ -16,7 +10,6 @@ describe("Functions module currentweather", function() {
Module.definitions[name] = moduleDefinition;
};
before(function(){
require("../../../modules/default/currentweather/currentweather.js");
Module.definitions.currentweather.config = {};
@@ -39,7 +32,7 @@ describe("Functions module currentweather", function() {
[2.0 , "2"],
["2.12" , "2"],
[10.1 , "10"]
]
];
values.forEach(value => {
it(`for ${value[0]} should be return ${value[1]}`, function() {
@@ -48,7 +41,6 @@ describe("Functions module currentweather", function() {
});
});
describe("this.config.roundTemp is false", function() {
before(function(){
@@ -66,7 +58,7 @@ describe("Functions module currentweather", function() {
["2.12" , "2.1"],
[10.1 , "10.1"],
[10.10 , "10.1"]
]
];
values.forEach(value => {
it(`for ${value[0]} should be return ${value[1]}`, function() {

View File

@@ -1,13 +1,8 @@
var fs = require("fs");
var path = require("path");
var chai = require("chai");
var expect = chai.expect;
var vm = require("vm");
var expect = require("chai").expect;
describe("Functions into modules/default/newsfeed/newsfeed.js", function() {
Module = {}
Module = {};
Module.definitions = {};
Module.register = function (name, moduleDefinition) {
Module.definitions[name] = moduleDefinition;
@@ -32,6 +27,5 @@ describe("Functions into modules/default/newsfeed/newsfeed.js", function() {
});
});
});
});

View File

@@ -1,9 +1,4 @@
var fs = require("fs");
var path = require("path");
var chai = require("chai");
var expect = chai.expect;
var vm = require("vm");
var expect = require("chai").expect;
describe("Functions module weatherforecast", function() {
@@ -35,7 +30,7 @@ describe("Functions module weatherforecast", function() {
[2.0 , "2"],
["2.12" , "2"],
[10.1 , "10"]
]
];
values.forEach(value => {
it(`for ${value[0]} should be return ${value[1]}`, function() {
@@ -44,7 +39,6 @@ describe("Functions module weatherforecast", function() {
});
});
describe("this.config.roundTemp is false", function() {
before(function(){
@@ -62,7 +56,7 @@ describe("Functions module weatherforecast", function() {
["2.12" , "2.1"],
[10.1 , "10.1"],
[10.10 , "10.1"]
]
];
values.forEach(value => {
it(`for ${value[0]} should be return ${value[1]}`, function() {

View File

@@ -1,7 +1,6 @@
var fs = require("fs");
var path = require("path");
var chai = require("chai");
var expect = chai.expect;
var expect = require("chai").expect;
var vm = require("vm");
before(function() {
@@ -62,5 +61,4 @@ describe("Default modules set in modules/default/defaultmodules.js", function()
expect(fs.existsSync(path.join(this.sandbox.global.root_path, "modules/default", defaultModule))).to.equal(true);
});
});
});

View File

@@ -1,7 +1,6 @@
var fs = require("fs");
var path = require("path");
var chai = require("chai");
var expect = chai.expect;
var expect = require("chai").expect;
var vm = require("vm");
before(function() {
@@ -66,6 +65,4 @@ describe("'global.root_path' set in js/app.js", function() {
versionPackage = JSON.parse(fs.readFileSync("package.json", "utf8")).version;
expect(this.sandbox.global.version).to.equal(versionPackage);
});
});