update module clock

This commit is contained in:
Karsten Hassel 2021-09-26 21:58:59 +02:00
parent 385e5aabaa
commit a4a8504558
12 changed files with 169 additions and 155 deletions

View File

@ -3,8 +3,12 @@
* By Sergey Morozov
* MIT Licensed.
*/
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
let config = {
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
language: "en",
timeFormat: 12,
units: "metric",
modules: [
{
@ -12,7 +16,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
position: "middle_center"
}
]
});
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {

View File

@ -3,14 +3,20 @@
* By Sergey Morozov
* MIT Licensed.
*/
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
let config = {
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
language: "en",
timeFormat: 24,
units: "metric",
modules: [
{
module: "clock",
position: "middle_center"
}
]
});
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {

View File

@ -2,7 +2,13 @@
*
* MIT Licensed.
*/
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
let config = {
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
language: "en",
timeFormat: 24,
units: "metric",
modules: [
{
module: "clock",
@ -13,7 +19,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
}
}
]
});
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {

View File

@ -3,8 +3,12 @@
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
* MIT Licensed.
*/
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
let config = {
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
language: "en",
timeFormat: 12,
units: "metric",
modules: [
{
@ -15,7 +19,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
}
}
]
});
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {

View File

@ -3,8 +3,12 @@
* By Sergey Morozov
* MIT Licensed.
*/
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
let config = {
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
language: "en",
timeFormat: 12,
units: "metric",
modules: [
{
@ -15,7 +19,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
}
}
]
});
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {

View File

@ -3,8 +3,12 @@
* By Johan Hammar
* MIT Licensed.
*/
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
let config = {
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
language: "en",
timeFormat: 12,
units: "metric",
modules: [
{
@ -15,7 +19,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
}
}
]
});
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {

View File

@ -3,8 +3,12 @@
* By Johan Hammar
* MIT Licensed.
*/
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
let config = {
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
language: "en",
timeFormat: 12,
units: "metric",
modules: [
{
@ -15,7 +19,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
}
}
]
});
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {

View File

@ -0,0 +1,116 @@
const helpers = require("../global-setup");
const moment = require("moment");
describe("Clock module", function () {
afterAll(function () {
helpers.stopApplication();
});
const testMatch = function (element, regex) {
const elem = document.querySelector(element);
expect(elem).not.toBe(null);
expect(elem.textContent).toMatch(regex);
};
describe("with default 24hr clock config", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/clock/clock_24hr.js");
helpers.getDocument(done, 1000);
});
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}$/;
testMatch(".clock .date", dateRegex);
});
it("should show the time in 24hr format", function () {
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
testMatch(".clock .time", timeRegex);
});
});
describe("with default 12hr clock config", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/clock/clock_12hr.js");
helpers.getDocument(done, 1000);
});
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}$/;
testMatch(".clock .date", dateRegex);
});
it("should show the time in 12hr format", function () {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
testMatch(".clock .time", timeRegex);
});
});
describe("with showPeriodUpper config enabled", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/clock/clock_showPeriodUpper.js");
helpers.getDocument(done, 1000);
});
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$/;
testMatch(".clock .time", timeRegex);
});
});
describe("with displaySeconds config disabled", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/clock/clock_displaySeconds_false.js");
helpers.getDocument(done, 1000);
});
it("should show 12hr time without seconds am/pm", function () {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/;
testMatch(".clock .time", timeRegex);
});
});
describe("with showTime config disabled", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/clock/clock_showTime.js");
helpers.getDocument(done, 1000);
});
it("should show not show the time when digital clock is shown", function () {
const elem = document.querySelector(".clock .digital .time");
expect(elem).toBe(null);
});
});
describe("with showWeek config enabled", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/clock/clock_showWeek.js");
helpers.getDocument(done, 1000);
});
it("should show the week in the correct format", function () {
const weekRegex = /^Week [0-9]{1,2}$/;
testMatch(".clock .week", weekRegex);
});
it("should show the week with the correct number of week of year", function () {
const currentWeekNumber = moment().week();
const weekToShow = "Week " + currentWeekNumber;
const elem = document.querySelector(".clock .week");
expect(elem).not.toBe(null);
expect(elem.textContent).toBe(weekToShow);
});
});
describe("with analog clock face enabled", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/clock/clock_analog.js");
helpers.getDocument(done, 1000);
});
it("should show the analog clock face", () => {
const elem = document.querySelector(".clockCircle");
expect(elem).not.toBe(null);
});
});
});

View File

@ -56,7 +56,7 @@ describe("Compliments module", function () {
helpers.getDocument(done, 1000);
});
it("Show anytime because if configure empty parts of day compliments and set anytime compliments", async function () {
it("Show anytime because if configure empty parts of day compliments and set anytime compliments", function () {
doTest(["Anytime here"]);
});
});
@ -67,7 +67,7 @@ describe("Compliments module", function () {
helpers.getDocument(done, 1000);
});
it("Show anytime compliments", async function () {
it("Show anytime compliments", function () {
doTest(["Anytime here"]);
});
});
@ -80,7 +80,7 @@ describe("Compliments module", function () {
helpers.getDocument(done, 1000);
});
it("Show happy new year compliment on new years day", async function () {
it("Show happy new year compliment on new years day", function () {
doTest(["Happy new year!"]);
});
});

View File

@ -11,7 +11,7 @@ describe("Test helloworld module", function () {
helpers.getDocument(done, 1000);
});
it("Test message helloworld module", async function () {
it("Test message helloworld module", function () {
const elem = document.querySelector(".helloworld");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Test HelloWorld Module");
@ -24,7 +24,7 @@ describe("Test helloworld module", function () {
helpers.getDocument(done, 1000);
});
it("Test message helloworld module", async function () {
it("Test message helloworld module", function () {
const elem = document.querySelector(".helloworld");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Hello World!");

View File

@ -23,7 +23,7 @@ describe("Newsfeed module", function () {
expect(elem.textContent).toContain("QPanel");
});
it("should NOT show the newsfeed description", async () => {
it("should NOT show the newsfeed description", () => {
const elem = document.querySelector(".newsfeed .newsfeed-desc");
expect(elem).toBe(null);
});
@ -41,7 +41,7 @@ describe("Newsfeed module", function () {
expect(elem.textContent).toContain("Problema VirtualBox");
});
it("should show the newsfeed description", async () => {
it("should show the newsfeed description", () => {
const elem = document.querySelector(".newsfeed .newsfeed-desc");
expect(elem).not.toBe(null);
expect(elem.textContent.length).not.toBe(0);

View File

@ -1,134 +0,0 @@
const helpers = require("../global-setup");
const moment = require("moment");
describe("Clock module", function () {
helpers.setupTimeout(this);
let app = null;
const testMatch = async function (element, regex) {
await app.client.waitUntilWindowLoaded();
const elem = await app.client.$(element);
const txt = await elem.getText(element);
return expect(txt).toMatch(regex);
};
beforeEach(function () {
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
});
afterEach(function () {
return helpers.stopApplication(app);
});
describe("with default 24hr clock config", function () {
beforeAll(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_24hr.js";
});
it("should show the date in the correct format", async 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 testMatch(".clock .date", dateRegex);
});
it("should show the time in 24hr format", async function () {
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
return testMatch(".clock .time", timeRegex);
});
});
describe("with default 12hr clock config", function () {
beforeAll(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_12hr.js";
});
it("should show the date in the correct format", async 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 testMatch(".clock .date", dateRegex);
});
it("should show the time in 12hr format", async function () {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
return testMatch(".clock .time", timeRegex);
});
});
describe("with showPeriodUpper config enabled", function () {
beforeAll(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showPeriodUpper.js";
});
it("should show 12hr time with upper case AM/PM", async function () {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
return testMatch(".clock .time", timeRegex);
});
});
describe("with displaySeconds config disabled", function () {
beforeAll(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_displaySeconds_false.js";
});
it("should show 12hr time without seconds am/pm", async function () {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/;
return testMatch(".clock .time", timeRegex);
});
});
describe("with showTime config disabled", function () {
beforeAll(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showTime.js";
});
it("should show not show the time when digital clock is shown", async function () {
await app.client.waitUntilWindowLoaded();
const time = await app.client.$$(".clock .digital .time");
return expect(time.length).toBe(0);
});
});
describe("with showWeek config enabled", function () {
beforeAll(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showWeek.js";
});
it("should show the week in the correct format", async function () {
const weekRegex = /^Week [0-9]{1,2}$/;
return testMatch(".clock .week", weekRegex);
});
it("should show the week with the correct number of week of year", async function () {
const currentWeekNumber = moment().week();
const weekToShow = "Week " + currentWeekNumber;
await app.client.waitUntilWindowLoaded();
const elem = await app.client.$(".clock .week");
const txt = await elem.getText(".clock .week");
return expect(txt).toBe(weekToShow);
});
});
describe("with analog clock face enabled", function () {
beforeAll(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();
const clock = await app.client.$$(".clockCircle");
return expect(clock.length).toBe(1);
});
});
});