From 60c5d96037b4316f95dc7c41f8711404bcefa8f2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?=
Date: Mon, 27 Mar 2017 12:18:36 -0300
Subject: [PATCH 01/14] fix documentation currentweather and weatherforecast
function roundValue:
This function toFixed return a string type not a number value.
---
modules/default/currentweather/currentweather.js | 2 +-
modules/default/weatherforecast/weatherforecast.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js
index 1b55e255..e2ca15b5 100644
--- a/modules/default/currentweather/currentweather.js
+++ b/modules/default/currentweather/currentweather.js
@@ -443,7 +443,7 @@ Module.register("currentweather",{
*
* argument temperature number - Temperature.
*
- * return number - Rounded Temperature.
+ * return string - Rounded Temperature.
*/
roundValue: function(temperature) {
var decimals = this.config.roundTemp ? 0 : 1;
diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js
index b269a44a..faed2c9f 100644
--- a/modules/default/weatherforecast/weatherforecast.js
+++ b/modules/default/weatherforecast/weatherforecast.js
@@ -356,7 +356,7 @@ Module.register("weatherforecast",{
*
* argument temperature number - Temperature.
*
- * return number - Rounded Temperature.
+ * return string - Rounded Temperature.
*/
roundValue: function(temperature) {
var decimals = this.config.roundTemp ? 0 : 1;
From 181cb235dfb1638bbe74ae4a9bceabd9fbc34ccc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?=
Date: Mon, 27 Mar 2017 14:01:30 -0300
Subject: [PATCH 02/14] Unit test currentweather module:
Add roundValue unit test function currentweather module
tests for this.config.roundTemp is true
---
tests/unit/functions/currentweather_spec.js | 45 +++++++++++++++++++++
1 file changed, 45 insertions(+)
create mode 100644 tests/unit/functions/currentweather_spec.js
diff --git a/tests/unit/functions/currentweather_spec.js b/tests/unit/functions/currentweather_spec.js
new file mode 100644
index 00000000..6252777d
--- /dev/null
+++ b/tests/unit/functions/currentweather_spec.js
@@ -0,0 +1,45 @@
+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 calendar.js
+ Module = {}
+ Module.definitions = {};
+ Module.register = function (name, moduleDefinition) {
+ Module.definitions[name] = moduleDefinition;
+ };
+ config = {};
+
+ describe("roundValue", function() {
+ describe("this.config.roundTemp is true", function() {
+ // load currentweather
+ require("../../../modules/default/currentweather/currentweather.js");
+
+ Module.definitions.currentweather.config = {};
+ 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]);
+ });
+ });
+ });
+ });
+});
From af9fdfa224d28ecbf958221b720cb3fe5979f8e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?=
Date: Tue, 28 Mar 2017 22:15:48 -0300
Subject: [PATCH 03/14] Add roundValue unit test function currentweather
module: - tests for this.config.roundTemp is false
---
tests/unit/functions/currentweather_spec.js | 53 ++++++++++++++++-----
1 file changed, 41 insertions(+), 12 deletions(-)
diff --git a/tests/unit/functions/currentweather_spec.js b/tests/unit/functions/currentweather_spec.js
index 6252777d..8744fce2 100644
--- a/tests/unit/functions/currentweather_spec.js
+++ b/tests/unit/functions/currentweather_spec.js
@@ -7,21 +7,23 @@ var vm = require("vm");
describe("Functions module currentweather", function() {
- // Fake for use by calendar.js
- Module = {}
- Module.definitions = {};
- Module.register = function (name, moduleDefinition) {
- Module.definitions[name] = moduleDefinition;
- };
- config = {};
+ before(function(){
+ Module = {};
+ config = {};
+ Module.definitions = {};
+ Module.register = function (name, moduleDefinition) {
+ Module.definitions[name] = moduleDefinition;
+ };
+ require("../../../modules/default/currentweather/currentweather.js");
+ Module.definitions.currentweather.config = {};
+ });
describe("roundValue", function() {
- describe("this.config.roundTemp is true", function() {
- // load currentweather
- require("../../../modules/default/currentweather/currentweather.js");
- Module.definitions.currentweather.config = {};
- Module.definitions.currentweather.config.roundTemp = true;
+ describe("this.config.roundTemp is true", function() {
+ before(function(){
+ Module.definitions.currentweather.config.roundTemp = true;
+ });
var values = [
// index 0 value
@@ -41,5 +43,32 @@ describe("Functions module currentweather", function() {
});
});
});
+
+
+ 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]);
+ });
+ });
+ });
});
});
From 947c2e556d81287e06521a53b0975e2ae61fa3ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?=
Date: Sun, 9 Apr 2017 15:32:15 -0300
Subject: [PATCH 04/14] Add test e2e showWeek feature in spanish language.
---
CHANGELOG.md | 1 +
.../modules/clock/es/clock_showWeek.js | 38 +++++++++++++++++++
tests/e2e/modules/clock_es_spec.js | 23 +++++++++++
3 files changed, 62 insertions(+)
create mode 100644 tests/configs/modules/clock/es/clock_showWeek.js
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 22aa51ad..ba54034c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Add in option to wrap long calendar events to multiple lines using `wrapEvents` configuration option.
- Add test e2e `show title newsfeed` for newsfeed module.
- Add task to check configuration file.
+- Add test e2e showWeek feature in spanish language.
### Updated
- Added missing keys to Polish translation.
diff --git a/tests/configs/modules/clock/es/clock_showWeek.js b/tests/configs/modules/clock/es/clock_showWeek.js
new file mode 100644
index 00000000..29550f04
--- /dev/null
+++ b/tests/configs/modules/clock/es/clock_showWeek.js
@@ -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;}
diff --git a/tests/e2e/modules/clock_es_spec.js b/tests/e2e/modules/clock_es_spec.js
index f90263cf..09fadc7a 100644
--- a/tests/e2e/modules/clock_es_spec.js
+++ b/tests/e2e/modules/clock_es_spec.js
@@ -78,4 +78,27 @@ describe("Clock set to spanish language module", function () {
.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";
+ });
+
+ beforeEach(function (done) {
+ app.start().then(function() { done(); } );
+ });
+
+ afterEach(function (done) {
+ app.stop().then(function() { done(); });
+ });
+
+ 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);
+ });
+ });
+
});
From 84dc0b29595694003be8ed136b531de77b96bf28 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?=
Date: Tue, 25 Jul 2017 10:28:17 -0400
Subject: [PATCH 05/14] Set version spectron for 3.6.x
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index fe64cc41..9f9afeaf 100644
--- a/package.json
+++ b/package.json
@@ -44,7 +44,7 @@
"http-auth": "^3.1.3",
"jshint": "^2.9.4",
"mocha": "^3.4.2",
- "spectron": "^3.6.4",
+ "spectron": "3.6.x",
"stylelint": "^7.11.0",
"stylelint-config-standard": "latest",
"time-grunt": "latest"
From 765b03c86897806051c5b56a48ffe5f71a03c958 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?=
Date: Tue, 25 Jul 2017 11:26:01 -0400
Subject: [PATCH 06/14] Add warning color when are using full ip whitelist
---
js/server.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/js/server.js b/js/server.js
index 78aac2fe..fbc51cbc 100644
--- a/js/server.js
+++ b/js/server.js
@@ -13,6 +13,7 @@ var path = require("path");
var ipfilter = require("express-ipfilter").IpFilter;
var fs = require("fs");
var helmet = require("helmet");
+var Utils = require(__dirname + "/utils.js");
var Server = function(config, callback) {
@@ -26,7 +27,7 @@ var Server = function(config, callback) {
server.listen(port, config.address ? config.address : null);
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) {
From 59aa84f6c8b9fcf056206ae5a0621761974b787e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?=
Date: Tue, 25 Jul 2017 17:52:44 -0400
Subject: [PATCH 07/14] Add log when clientonly failed on starting.
---
clientonly/index.js | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/clientonly/index.js b/clientonly/index.js
index 750a98e6..72495504 100644
--- a/clientonly/index.js
+++ b/clientonly/index.js
@@ -87,6 +87,13 @@
child.on("error", function (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) {
fail(`Unable to connect to server: (${reason})`);
@@ -94,4 +101,4 @@
} else {
fail();
}
-}());
\ No newline at end of file
+}());
From 5ac20cc4cf24712499d13f089fa1e7a8621c64b2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?=
Date: Tue, 25 Jul 2017 21:36:30 -0400
Subject: [PATCH 08/14] SuiteTest: Added unit tests for js/class.js
---
CHANGELOG.md | 1 +
js/class.js | 7 +++-
tests/unit/functions/class_spec.js | 51 ++++++++++++++++++++++++++++++
3 files changed, 58 insertions(+), 1 deletion(-)
create mode 100644 tests/unit/functions/class_spec.js
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 90bae37b..55dbf419 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Add `clientonly` script to start only the electron client for a remote server.
- Add symbol and color properties of event when `CALENDAR_EVENTS` notification is broadcasted from `default/calendar` module.
- Add `.vscode/` folder to `.gitignore` to keep custom Visual Studio Code config out of git
+- Add unit test for js/class.js.
### Updated
- Changed 'default.js' - listen on all attached interfaces by default
diff --git a/js/class.js b/js/class.js
index f2fa5159..ec75f6f2 100644
--- a/js/class.js
+++ b/js/class.js
@@ -90,4 +90,9 @@ function cloneObject(obj) {
}
/*************** 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
+ }
+}
diff --git a/tests/unit/functions/class_spec.js b/tests/unit/functions/class_spec.js
new file mode 100644
index 00000000..e2e6d521
--- /dev/null
+++ b/tests/unit/functions/class_spec.js
@@ -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);
+ });
+ });
+ */
+
+ });
+});
+
From 353786cb616dcd275690c074d13dd1f2cc3d8c0a Mon Sep 17 00:00:00 2001
From: Cato Antonsen
Date: Thu, 3 Aug 2017 21:34:23 +0200
Subject: [PATCH 09/14] Fix this.file path
---
CHANGELOG.md | 1 +
js/module.js | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5f762dbe..01c73ee5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- 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 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
diff --git a/js/module.js b/js/module.js
index 0d51e559..413efa46 100644
--- a/js/module.js
+++ b/js/module.js
@@ -194,7 +194,7 @@ var Module = Class.extend({
* return string - File path.
*/
file: function (file) {
- return this.data.path + "/" + file;
+ return (this.data.path + "/" + file).replace("//", "/");
},
/* loadStyles()
From 6abd120a5cccb09219be17694306ef0b7c30c196 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?=
Date: Fri, 4 Aug 2017 22:39:52 -0400
Subject: [PATCH 10/14] Add CHANGELOG entry for color in warning if full ip
whitelist
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5f762dbe..b3cbb733 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Changed 'default.js' - listen on all attached interfaces by default.
- Add execution of `npm list` after the test are ran in Travis CI.
- Change hooks for the vendors e2e tests.
+- Add warning color when are using full ip whitelist.
### Fixed
- Fixed issue with incorrect allignment of analog clock when displayed in the center column of the MM.
From f144ec67ab2e37dabde4e7e99c2da7be6a231f08 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?=
Date: Sat, 5 Aug 2017 17:48:20 -0400
Subject: [PATCH 11/14] Add changelog entry for log in failed of clientonly
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5f762dbe..19efd5bc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Changed 'default.js' - listen on all attached interfaces by default.
- 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.
### Fixed
- Fixed issue with incorrect allignment of analog clock when displayed in the center column of the MM.
From d34b493b7d84d7909e55a153cde0cde79eeb360c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?=
Date: Sat, 5 Aug 2017 22:30:38 -0400
Subject: [PATCH 12/14] Fix clock_es_spec running before the clock_spec
---
tests/e2e/modules/clock_es_spec.js | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/tests/e2e/modules/clock_es_spec.js b/tests/e2e/modules/clock_es_spec.js
index f959e09b..455f3bed 100644
--- a/tests/e2e/modules/clock_es_spec.js
+++ b/tests/e2e/modules/clock_es_spec.js
@@ -74,21 +74,12 @@ describe("Clock set to spanish language module", function() {
});
});
-
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";
});
- beforeEach(function (done) {
- app.start().then(function() { done(); } );
- });
-
- afterEach(function (done) {
- app.stop().then(function() { done(); });
- });
-
it("shows week with correct format", function() {
const weekRegex = /^Semana [0-9]{1,2}$/;
return app.client.waitUntilWindowLoaded()
From 7fc82ccead6debd1df6fd73fa8b299aa83323359 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?=
Date: Mon, 7 Aug 2017 20:42:32 -0400
Subject: [PATCH 13/14] Update Changelog for unit tests for currentweather
module
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5f762dbe..34cd778d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Add `.vscode/` folder to `.gitignore` to keep custom Visual Studio Code config out of git.
- Add unit test the capitalizeFirstLetter function of newfeed module.
- Add new unit tests for function `shorten` in calendar module.
+- Add unit tests for function `roundValue` in currentweather module.
### Updated
- Changed 'default.js' - listen on all attached interfaces by default.
From 739fb99cedef43bb30b978f2f559c0c02ad0c228 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?=
Date: Sun, 6 Aug 2017 07:53:03 -0400
Subject: [PATCH 14/14] Resolved conflict unit tests between currentweather and
newsfeed.
---
tests/unit/functions/currentweather_spec.js | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/tests/unit/functions/currentweather_spec.js b/tests/unit/functions/currentweather_spec.js
index 8744fce2..18b52c81 100644
--- a/tests/unit/functions/currentweather_spec.js
+++ b/tests/unit/functions/currentweather_spec.js
@@ -7,13 +7,17 @@ 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(){
- Module = {};
- config = {};
- Module.definitions = {};
- Module.register = function (name, moduleDefinition) {
- Module.definitions[name] = moduleDefinition;
- };
require("../../../modules/default/currentweather/currentweather.js");
Module.definitions.currentweather.config = {};
});