From 45f09dcc8c78c3c2aaee9f9057aebcda56c0be95 Mon Sep 17 00:00:00 2001 From: rejas Date: Tue, 21 Jul 2020 11:27:45 +0200 Subject: [PATCH 1/4] Add test for analog clock face --- tests/configs/modules/clock/clock_analog.js | 33 +++++++++++++++++++++ tests/e2e/modules/clock_spec.js | 30 ++++++++++++++----- 2 files changed, 55 insertions(+), 8 deletions(-) create mode 100644 tests/configs/modules/clock/clock_analog.js diff --git a/tests/configs/modules/clock/clock_analog.js b/tests/configs/modules/clock/clock_analog.js new file mode 100644 index 00000000..a353e0f4 --- /dev/null +++ b/tests/configs/modules/clock/clock_analog.js @@ -0,0 +1,33 @@ +/* Magic Mirror Test config for analog clock face + * + * MIT Licensed. + */ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + + language: "en", + timeFormat: 24, + units: "metric", + electronOptions: { + webPreferences: { + nodeIntegration: true + } + }, + + modules: [ + { + module: "clock", + position: "middle_center", + config: { + displayType: "analog", + analogFace: "face-006" + } + } + ] +}; + +/*************** DO NOT EDIT THE LINE BELOW ***************/ +if (typeof module !== "undefined") { + module.exports = config; +} diff --git a/tests/e2e/modules/clock_spec.js b/tests/e2e/modules/clock_spec.js index 372d61af..fb3cae37 100644 --- a/tests/e2e/modules/clock_spec.js +++ b/tests/e2e/modules/clock_spec.js @@ -1,4 +1,5 @@ const helpers = require("../global-setup"); +const expect = require("chai").expect; const describe = global.describe; const it = global.it; @@ -30,12 +31,12 @@ describe("Clock module", function () { process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_24hr.js"; }); - it("shows date with correct format", function () { + it("should show the date in the correct format", function () { const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/; return app.client.waitUntilWindowLoaded().getText(".clock .date").should.eventually.match(dateRegex); }); - it("shows time in 24hr format", function () { + it("should show the time in 24hr format", function () { const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/; return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex); }); @@ -47,12 +48,12 @@ describe("Clock module", function () { process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_12hr.js"; }); - it("shows date with correct format", function () { + it("should show the date in the correct format", function () { const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/; return app.client.waitUntilWindowLoaded().getText(".clock .date").should.eventually.match(dateRegex); }); - it("shows time in 12hr format", function () { + it("should show the time in 12hr format", function () { const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/; return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex); }); @@ -64,7 +65,7 @@ describe("Clock module", function () { process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showPeriodUpper.js"; }); - it("shows 12hr time with upper case AM/PM", function () { + it("should show 12hr time with upper case AM/PM", function () { const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/; return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex); }); @@ -76,7 +77,7 @@ describe("Clock module", function () { process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_displaySeconds_false.js"; }); - it("shows 12hr time without seconds am/pm", function () { + it("should show 12hr time without seconds am/pm", function () { const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/; return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex); }); @@ -88,12 +89,12 @@ describe("Clock module", function () { process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showWeek.js"; }); - it("shows week with correct format", function () { + it("should show the week in the correct format", function () { const weekRegex = /^Week [0-9]{1,2}$/; return app.client.waitUntilWindowLoaded().getText(".clock .week").should.eventually.match(weekRegex); }); - it("shows week with correct number of week of year", function () { + it("should show the week with the correct number of week of year", function () { it("FIXME: if the day is a sunday this not match"); // const currentWeekNumber = require("current-week-number")(); // const weekToShow = "Week " + currentWeekNumber; @@ -101,4 +102,17 @@ describe("Clock module", function () { // .getText(".clock .week").should.eventually.equal(weekToShow); }); }); + + describe("with analog clock face enabled", function () { + before(function () { + // Set config sample for use in test + process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_analog.js"; + }); + + it("should show the analog clock face", async () => { + await app.client.waitUntilWindowLoaded(10000); + const clock = await app.client.$$(".clockCircle"); + return expect(clock.length).equals(1); + }); + }); }); From a1a4192835a23116d3d7cf9b7e72313d458f8195 Mon Sep 17 00:00:00 2001 From: rejas Date: Sun, 2 Aug 2020 15:19:36 +0200 Subject: [PATCH 2/4] Fix clock test, remove now unneeded dependency --- package-lock.json | 6 ------ package.json | 1 - tests/e2e/modules/clock_spec.js | 9 ++++----- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index a3214e7a..5283bf04 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1745,12 +1745,6 @@ "cssom": "0.3.x" } }, - "current-week-number": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/current-week-number/-/current-week-number-1.0.7.tgz", - "integrity": "sha1-VnJ4rrX+WN7LFQuayGT5Pc5O2XI=", - "dev": true - }, "currently-unhandled": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", diff --git a/package.json b/package.json index f2e95b7c..bc47eb01 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ "@prantlf/jsonlint": "^10.2.0", "chai": "^4.2.0", "chai-as-promised": "^7.1.1", - "current-week-number": "^1.0.7", "danger": "^3.1.3", "eslint-config-prettier": "^6.11.0", "eslint-plugin-jsdoc": "^30.1.0", diff --git a/tests/e2e/modules/clock_spec.js b/tests/e2e/modules/clock_spec.js index fb3cae37..2bf148c6 100644 --- a/tests/e2e/modules/clock_spec.js +++ b/tests/e2e/modules/clock_spec.js @@ -1,5 +1,6 @@ const helpers = require("../global-setup"); const expect = require("chai").expect; +const moment = require("moment"); const describe = global.describe; const it = global.it; @@ -95,11 +96,9 @@ describe("Clock module", function () { }); it("should show the week with the correct number of week of year", function () { - it("FIXME: if the day is a sunday this not match"); - // const currentWeekNumber = require("current-week-number")(); - // const weekToShow = "Week " + currentWeekNumber; - // return app.client.waitUntilWindowLoaded() - // .getText(".clock .week").should.eventually.equal(weekToShow); + const currentWeekNumber = moment().week(); + const weekToShow = "Week " + currentWeekNumber; + return app.client.waitUntilWindowLoaded().getText(".clock .week").should.eventually.equal(weekToShow); }); }); From 259068b8604f745794841a4097fa1e07d1e73efb Mon Sep 17 00:00:00 2001 From: rejas Date: Sun, 2 Aug 2020 15:23:22 +0200 Subject: [PATCH 3/4] Remove unused dependency, update eslint --- package-lock.json | 24 +++--------------------- package.json | 3 +-- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5283bf04..28eb8197 100644 --- a/package-lock.json +++ b/package-lock.json @@ -601,24 +601,6 @@ "url-template": "^2.0.8" } }, - "@prantlf/jsonlint": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/@prantlf/jsonlint/-/jsonlint-10.2.0.tgz", - "integrity": "sha512-KMFfds0peWLLfCu3bhClTiEN0tdj/Z86QJvn1awKHws6r+Sx6T3a44Eadz6OvqN6ZpsRkqaRpZxqddvvDAdDZQ==", - "dev": true, - "requires": { - "ajv": "6.10.2", - "commander": "4.0.1" - }, - "dependencies": { - "commander": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-4.0.1.tgz", - "integrity": "sha512-IPF4ouhCP+qdlcmCedhxX4xiGBPyigb8v5NeUp+0LyhwLgxMqyp3S0vl7TAPfS/hiP7FC3caI/PB9lTmP8r1NA==", - "dev": true - } - } - }, "@stylelint/postcss-css-in-js": { "version": "0.37.1", "resolved": "https://registry.npmjs.org/@stylelint/postcss-css-in-js/-/postcss-css-in-js-0.37.1.tgz", @@ -2378,9 +2360,9 @@ } }, "eslint": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.5.0.tgz", - "integrity": "sha512-vlUP10xse9sWt9SGRtcr1LAC67BENcQMFeV+w5EvLEoFe3xJ8cF1Skd0msziRx/VMC+72B4DxreCE+OR12OA6Q==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.6.0.tgz", + "integrity": "sha512-QlAManNtqr7sozWm5TF4wIH9gmUm2hE3vNRUvyoYAa4y1l5/jxD/PQStEjBMQtCqZmSep8UxrcecI60hOpe61w==", "requires": { "@babel/code-frame": "^7.0.0", "ajv": "^6.10.0", diff --git a/package.json b/package.json index bc47eb01..5eb4d6b4 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ }, "homepage": "https://magicmirror.builders", "devDependencies": { - "@prantlf/jsonlint": "^10.2.0", "chai": "^4.2.0", "chai-as-promised": "^7.1.1", "danger": "^3.1.3", @@ -70,7 +69,7 @@ "dependencies": { "colors": "^1.1.2", "console-stamp": "^0.2.9", - "eslint": "^7.5.0", + "eslint": "^7.6.0", "express": "^4.16.2", "express-ipfilter": "^1.0.1", "feedme": "latest", From 14e8cdd9b2abdd55c63e869a35eaca4651e2e79e Mon Sep 17 00:00:00 2001 From: rejas Date: Sun, 2 Aug 2020 15:39:10 +0200 Subject: [PATCH 4/4] Update Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b30f02fc..69291828 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ _This release is scheduled to be released on 2020-10-01._ - Change incorrect weather.js default properties. - Cleaned up newsfeed module. - Cleaned up jsdoc comments. +- Cleaned up clock tests. ### Deleted