diff --git a/tests/configs/modules/clock/clock_12hr.js b/tests/configs/modules/clock/clock_12hr.js index 35b45914..cb3563c7 100644 --- a/tests/configs/modules/clock/clock_12hr.js +++ b/tests/configs/modules/clock/clock_12hr.js @@ -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") { diff --git a/tests/configs/modules/clock/clock_24hr.js b/tests/configs/modules/clock/clock_24hr.js index 01b2a36b..f77a600d 100644 --- a/tests/configs/modules/clock/clock_24hr.js +++ b/tests/configs/modules/clock/clock_24hr.js @@ -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") { diff --git a/tests/configs/modules/clock/clock_analog.js b/tests/configs/modules/clock/clock_analog.js index b33bd051..7f1353c6 100644 --- a/tests/configs/modules/clock/clock_analog.js +++ b/tests/configs/modules/clock/clock_analog.js @@ -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") { diff --git a/tests/configs/modules/clock/clock_displaySeconds_false.js b/tests/configs/modules/clock/clock_displaySeconds_false.js index 1caef7e3..4e872377 100644 --- a/tests/configs/modules/clock/clock_displaySeconds_false.js +++ b/tests/configs/modules/clock/clock_displaySeconds_false.js @@ -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") { diff --git a/tests/configs/modules/clock/clock_showPeriodUpper.js b/tests/configs/modules/clock/clock_showPeriodUpper.js index b069c438..7ff7f20a 100644 --- a/tests/configs/modules/clock/clock_showPeriodUpper.js +++ b/tests/configs/modules/clock/clock_showPeriodUpper.js @@ -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") { diff --git a/tests/configs/modules/clock/clock_showTime.js b/tests/configs/modules/clock/clock_showTime.js index 93dd83de..2c130fb2 100644 --- a/tests/configs/modules/clock/clock_showTime.js +++ b/tests/configs/modules/clock/clock_showTime.js @@ -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") { diff --git a/tests/configs/modules/clock/clock_showWeek.js b/tests/configs/modules/clock/clock_showWeek.js index b595ba70..1db31cb6 100644 --- a/tests/configs/modules/clock/clock_showWeek.js +++ b/tests/configs/modules/clock/clock_showWeek.js @@ -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") { diff --git a/tests/e2e/modules/clock_spec.js b/tests/e2e/modules/clock_spec.js new file mode 100644 index 00000000..79e26f47 --- /dev/null +++ b/tests/e2e/modules/clock_spec.js @@ -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); + }); + }); +}); diff --git a/tests/e2e/modules/compliments_spec.js b/tests/e2e/modules/compliments_spec.js index 0f3b74e8..73f851c5 100644 --- a/tests/e2e/modules/compliments_spec.js +++ b/tests/e2e/modules/compliments_spec.js @@ -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!"]); }); }); diff --git a/tests/e2e/modules/helloworld_spec.js b/tests/e2e/modules/helloworld_spec.js index 8c11575a..d8f1a3c6 100644 --- a/tests/e2e/modules/helloworld_spec.js +++ b/tests/e2e/modules/helloworld_spec.js @@ -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!"); diff --git a/tests/e2e/modules/newsfeed_spec.js b/tests/e2e/modules/newsfeed_spec.js index 0b2869e2..d7a3b9fe 100644 --- a/tests/e2e/modules/newsfeed_spec.js +++ b/tests/e2e/modules/newsfeed_spec.js @@ -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); diff --git a/tests/electron/modules/clock_spec.js b/tests/electron/modules/clock_spec.js deleted file mode 100644 index c2e03fc9..00000000 --- a/tests/electron/modules/clock_spec.js +++ /dev/null @@ -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); - }); - }); -});