Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
30 changes: 3 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@
},
"homepage": "https://magicmirror.builders",
"devDependencies": {
"@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",
Expand All @@ -71,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",
Expand Down
33 changes: 33 additions & 0 deletions tests/configs/modules/clock/clock_analog.js
Original file line number Diff line number Diff line change
@@ -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;
}
39 changes: 26 additions & 13 deletions tests/e2e/modules/clock_spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const helpers = require("../global-setup");
const expect = require("chai").expect;
const moment = require("moment");

const describe = global.describe;
const it = global.it;
Expand Down Expand Up @@ -30,12 +32,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);
});
Expand All @@ -47,12 +49,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);
});
Expand All @@ -64,7 +66,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);
});
Expand All @@ -76,7 +78,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);
});
Expand All @@ -88,17 +90,28 @@ 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("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);
it("should show the week with the correct number of week of year", function () {
const currentWeekNumber = moment().week();
const weekToShow = "Week " + currentWeekNumber;
return app.client.waitUntilWindowLoaded().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);
});
});
});