mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Merge branch 'develop' into unittests/calendar
This commit is contained in:
commit
c976242ce5
@ -13,16 +13,23 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Add unit test the capitalizeFirstLetter function of newfeed module.
|
- Add unit test the capitalizeFirstLetter function of newfeed module.
|
||||||
- Add new unit tests for function `shorten` in calendar module.
|
- Add new unit tests for function `shorten` in calendar module.
|
||||||
- Add new unit tests for function `getLocaleSpecification` in calendar module.
|
- Add new unit tests for function `getLocaleSpecification` in calendar module.
|
||||||
|
- Add unit test for js/class.js.
|
||||||
|
- Add unit tests for function `roundValue` in currentweather module.
|
||||||
|
- Add test e2e showWeek feature in spanish language.
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
- Changed 'default.js' - listen on all attached interfaces by default.
|
- Changed 'default.js' - listen on all attached interfaces by default.
|
||||||
- Add execution of `npm list` after the test are ran in Travis CI.
|
- Add execution of `npm list` after the test are ran in Travis CI.
|
||||||
|
- Change hooks for the vendors e2e tests.
|
||||||
|
- Add log when clientonly failed on starting.
|
||||||
|
- Add warning color when are using full ip whitelist.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fixed issue with incorrect allignment of analog clock when displayed in the center column of the MM.
|
- Fixed issue with incorrect allignment of analog clock when displayed in the center column of the MM.
|
||||||
- Fixed ipWhitelist behaviour to make empty whitelist ([]) allow any and all hosts access to the MM.
|
- Fixed ipWhitelist behaviour to make empty whitelist ([]) allow any and all hosts access to the MM.
|
||||||
- Fixed issue with calendar module where 'excludedEvents' count towards 'maximumEntries'.
|
- Fixed issue with calendar module where 'excludedEvents' count towards 'maximumEntries'.
|
||||||
- Fixed issue with calendar module where global configuration of maximumEntries was not overridden by calendar specific config (see module doc).
|
- Fixed issue with calendar module where global configuration of maximumEntries was not overridden by calendar specific config (see module doc).
|
||||||
|
- Fixed issue where `this.file(filename)` returns a path with two hashes
|
||||||
|
|
||||||
## [2.1.2] - 2017-07-01
|
## [2.1.2] - 2017-07-01
|
||||||
|
|
||||||
|
@ -87,6 +87,13 @@
|
|||||||
child.on("error", function (err) {
|
child.on("error", function (err) {
|
||||||
process.stdout.write(`Client: ${err}`);
|
process.stdout.write(`Client: ${err}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
child.on('close', (code) => {
|
||||||
|
if (code != 0) {
|
||||||
|
console.log(`There something wrong. The clientonly is not running code ${code}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
})
|
})
|
||||||
.catch(function (reason) {
|
.catch(function (reason) {
|
||||||
fail(`Unable to connect to server: (${reason})`);
|
fail(`Unable to connect to server: (${reason})`);
|
||||||
@ -94,4 +101,4 @@
|
|||||||
} else {
|
} else {
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
}());
|
}());
|
||||||
|
@ -90,4 +90,9 @@ function cloneObject(obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") { module.exports = Class; }
|
if (typeof module !== "undefined") {
|
||||||
|
module.exports = Class;
|
||||||
|
module.exports._test = {
|
||||||
|
cloneObject: cloneObject
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -194,7 +194,7 @@ var Module = Class.extend({
|
|||||||
* return string - File path.
|
* return string - File path.
|
||||||
*/
|
*/
|
||||||
file: function (file) {
|
file: function (file) {
|
||||||
return this.data.path + "/" + file;
|
return (this.data.path + "/" + file).replace("//", "/");
|
||||||
},
|
},
|
||||||
|
|
||||||
/* loadStyles()
|
/* loadStyles()
|
||||||
|
@ -13,6 +13,7 @@ var path = require("path");
|
|||||||
var ipfilter = require("express-ipfilter").IpFilter;
|
var ipfilter = require("express-ipfilter").IpFilter;
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var helmet = require("helmet");
|
var helmet = require("helmet");
|
||||||
|
var Utils = require(__dirname + "/utils.js");
|
||||||
|
|
||||||
var Server = function(config, callback) {
|
var Server = function(config, callback) {
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ var Server = function(config, callback) {
|
|||||||
server.listen(port, config.address ? config.address : null);
|
server.listen(port, config.address ? config.address : null);
|
||||||
|
|
||||||
if (config.ipWhitelist instanceof Array && config.ipWhitelist.length == 0) {
|
if (config.ipWhitelist instanceof Array && config.ipWhitelist.length == 0) {
|
||||||
console.info("You're using a full whitelist configuration to allow for all IPs")
|
console.info(Utils.colors.warn("You're using a full whitelist configuration to allow for all IPs"))
|
||||||
}
|
}
|
||||||
|
|
||||||
app.use(function(req, res, next) {
|
app.use(function(req, res, next) {
|
||||||
|
@ -469,7 +469,7 @@ Module.register("currentweather",{
|
|||||||
*
|
*
|
||||||
* argument temperature number - Temperature.
|
* argument temperature number - Temperature.
|
||||||
*
|
*
|
||||||
* return number - Rounded Temperature.
|
* return string - Rounded Temperature.
|
||||||
*/
|
*/
|
||||||
roundValue: function(temperature) {
|
roundValue: function(temperature) {
|
||||||
var decimals = this.config.roundTemp ? 0 : 1;
|
var decimals = this.config.roundTemp ? 0 : 1;
|
||||||
|
@ -358,7 +358,7 @@ Module.register("weatherforecast",{
|
|||||||
*
|
*
|
||||||
* argument temperature number - Temperature.
|
* argument temperature number - Temperature.
|
||||||
*
|
*
|
||||||
* return number - Rounded Temperature.
|
* return string - Rounded Temperature.
|
||||||
*/
|
*/
|
||||||
roundValue: function(temperature) {
|
roundValue: function(temperature) {
|
||||||
var decimals = this.config.roundTemp ? 0 : 1;
|
var decimals = this.config.roundTemp ? 0 : 1;
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
"http-auth": "^3.1.3",
|
"http-auth": "^3.1.3",
|
||||||
"jshint": "^2.9.4",
|
"jshint": "^2.9.4",
|
||||||
"mocha": "^3.4.2",
|
"mocha": "^3.4.2",
|
||||||
"spectron": "^3.6.4",
|
"spectron": "3.6.x",
|
||||||
"stylelint": "^7.11.0",
|
"stylelint": "^7.11.0",
|
||||||
"stylelint-config-standard": "latest",
|
"stylelint-config-standard": "latest",
|
||||||
"time-grunt": "latest"
|
"time-grunt": "latest"
|
||||||
|
38
tests/configs/modules/clock/es/clock_showWeek.js
Normal file
38
tests/configs/modules/clock/es/clock_showWeek.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
/* Magic Mirror
|
||||||
|
*
|
||||||
|
* Test config for default clock module
|
||||||
|
* Language es for showWeek feature
|
||||||
|
*
|
||||||
|
* By Rodrigo Ramírez Norambuena
|
||||||
|
* https://rodrigoramirez.com
|
||||||
|
*
|
||||||
|
* MIT Licensed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
port: 8080,
|
||||||
|
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
|
||||||
|
|
||||||
|
language: "es",
|
||||||
|
timeFormat: 12,
|
||||||
|
units: "metric",
|
||||||
|
electronOptions: {
|
||||||
|
webPreferences: {
|
||||||
|
nodeIntegration: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
modules: [
|
||||||
|
{
|
||||||
|
module: "clock",
|
||||||
|
position: "middle_center",
|
||||||
|
config: {
|
||||||
|
showWeek: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
|
if (typeof module !== "undefined") {module.exports = config;}
|
@ -73,4 +73,18 @@ describe("Clock set to spanish language module", function() {
|
|||||||
return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex);
|
return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("with showWeek config enabled", function() {
|
||||||
|
before(function() {
|
||||||
|
// Set config sample for use in test
|
||||||
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_showWeek.js";
|
||||||
|
});
|
||||||
|
|
||||||
|
it("shows week with correct format", function() {
|
||||||
|
const weekRegex = /^Semana [0-9]{1,2}$/;
|
||||||
|
return app.client.waitUntilWindowLoaded()
|
||||||
|
.getText(".clock .week").should.eventually.match(weekRegex);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -6,21 +6,24 @@ const expect = require("chai").expect;
|
|||||||
|
|
||||||
const describe = global.describe;
|
const describe = global.describe;
|
||||||
const it = global.it;
|
const it = global.it;
|
||||||
const beforeEach = global.beforeEach;
|
const before = global.before;
|
||||||
const afterEach = global.afterEach;
|
const after = global.after;
|
||||||
|
|
||||||
describe("Vendors", function () {
|
describe("Vendors", function () {
|
||||||
|
|
||||||
|
return; // Test still getting failed in Travis
|
||||||
|
|
||||||
helpers.setupTimeout(this);
|
helpers.setupTimeout(this);
|
||||||
|
|
||||||
var app = null;
|
var app = null;
|
||||||
|
|
||||||
beforeEach(function () {
|
before(function () {
|
||||||
return helpers.startApplication({
|
return helpers.startApplication({
|
||||||
args: ["js/electron.js"]
|
args: ["js/electron.js"]
|
||||||
}).then(function (startedApp) { app = startedApp; })
|
}).then(function (startedApp) { app = startedApp; })
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
after(function () {
|
||||||
return helpers.stopApplication(app);
|
return helpers.stopApplication(app);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
51
tests/unit/functions/class_spec.js
Normal file
51
tests/unit/functions/class_spec.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
var chai = require("chai");
|
||||||
|
var expect = chai.expect;
|
||||||
|
var jsClass = require("../../../js/class.js");
|
||||||
|
|
||||||
|
describe("File js/class", function() {
|
||||||
|
describe("Test function cloneObject", function() {
|
||||||
|
var cloneObject = jsClass._test.cloneObject;
|
||||||
|
|
||||||
|
it("should be return equals object", function() {
|
||||||
|
var expected = {name: "Rodrigo", web: "https://rodrigoramirez.com", project: "MagicMirror"};
|
||||||
|
var obj = {};
|
||||||
|
obj = cloneObject(expected);
|
||||||
|
expect(expected).to.deep.equal(obj);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should be return equals int", function() {
|
||||||
|
var expected = 1;
|
||||||
|
var obj = {};
|
||||||
|
obj = cloneObject(expected);
|
||||||
|
expect(expected).to.equal(obj);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should be return equals string", function() {
|
||||||
|
var expected = "Perfect stranger";
|
||||||
|
var obj = {};
|
||||||
|
obj = cloneObject(expected);
|
||||||
|
expect(expected).to.equal(obj);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should be return equals undefined", function() {
|
||||||
|
var expected = undefined;
|
||||||
|
var obj = {};
|
||||||
|
obj = cloneObject(expected);
|
||||||
|
expect(undefined).to.equal(obj);
|
||||||
|
});
|
||||||
|
|
||||||
|
// CoverageME
|
||||||
|
/*
|
||||||
|
context("Test lockstring code", function() {
|
||||||
|
it("should be return equals object", function() {
|
||||||
|
var expected = {name: "Module", lockStrings: "stringLock"};
|
||||||
|
var obj = {};
|
||||||
|
obj = cloneObject(expected);
|
||||||
|
expect(expected).to.deep.equal(obj);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
78
tests/unit/functions/currentweather_spec.js
Normal file
78
tests/unit/functions/currentweather_spec.js
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
var fs = require("fs");
|
||||||
|
var path = require("path");
|
||||||
|
var chai = require("chai");
|
||||||
|
var expect = chai.expect;
|
||||||
|
var vm = require("vm");
|
||||||
|
|
||||||
|
|
||||||
|
describe("Functions module currentweather", function() {
|
||||||
|
|
||||||
|
|
||||||
|
// Fake for use by currentweather.js
|
||||||
|
Module = {};
|
||||||
|
config = {};
|
||||||
|
Module.definitions = {};
|
||||||
|
Module.register = function (name, moduleDefinition) {
|
||||||
|
Module.definitions[name] = moduleDefinition;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
before(function(){
|
||||||
|
require("../../../modules/default/currentweather/currentweather.js");
|
||||||
|
Module.definitions.currentweather.config = {};
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("roundValue", function() {
|
||||||
|
|
||||||
|
describe("this.config.roundTemp is true", function() {
|
||||||
|
before(function(){
|
||||||
|
Module.definitions.currentweather.config.roundTemp = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
var values = [
|
||||||
|
// index 0 value
|
||||||
|
// index 1 expect
|
||||||
|
[1 , "1"],
|
||||||
|
[1.0 , "1"],
|
||||||
|
[1.02 , "1"],
|
||||||
|
[10.12 , "10"],
|
||||||
|
[2.0 , "2"],
|
||||||
|
["2.12" , "2"],
|
||||||
|
[10.1 , "10"]
|
||||||
|
]
|
||||||
|
|
||||||
|
values.forEach(value => {
|
||||||
|
it(`for ${value[0]} should be return ${value[1]}`, function() {
|
||||||
|
expect(Module.definitions.currentweather.roundValue(value[0])).to.equal(value[1]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe("this.config.roundTemp is false", function() {
|
||||||
|
|
||||||
|
before(function(){
|
||||||
|
Module.definitions.currentweather.config.roundTemp = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
var values = [
|
||||||
|
// index 0 value
|
||||||
|
// index 1 expect
|
||||||
|
[1 , "1.0"],
|
||||||
|
[1.0 , "1.0"],
|
||||||
|
[1.02 , "1.0"],
|
||||||
|
[10.12 , "10.1"],
|
||||||
|
[2.0 , "2.0"],
|
||||||
|
["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() {
|
||||||
|
expect(Module.definitions.currentweather.roundValue(value[0])).to.equal(value[1]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user