mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Merge pull request #2912 from khassel/e2e
fix e2e tests not failing on errors
This commit is contained in:
commit
4381fc6695
@ -34,6 +34,7 @@ _This release is scheduled to be released on 2022-10-01._
|
|||||||
- Fix multi day calendar events always presented as "(1/X)" instead of the amount of days the event has progressed.
|
- Fix multi day calendar events always presented as "(1/X)" instead of the amount of days the event has progressed.
|
||||||
- Fix weatherbit provider to use type config value instead of endpoint
|
- Fix weatherbit provider to use type config value instead of endpoint
|
||||||
- Fix calendar events which DO NOT specify rrule byday adjusted incorrectly #2885
|
- Fix calendar events which DO NOT specify rrule byday adjusted incorrectly #2885
|
||||||
|
- Fix e2e tests not failing on errors (#2911)
|
||||||
|
|
||||||
## [2.20.0] - 2022-07-02
|
## [2.20.0] - 2022-07-02
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ BEGIN:STANDARD
|
|||||||
TZOFFSETFROM:+0000
|
TZOFFSETFROM:+0000
|
||||||
TZOFFSETTO:+0000
|
TZOFFSETTO:+0000
|
||||||
TZNAME:GMT
|
TZNAME:GMT
|
||||||
DTSTART:19700101T00000--äüüßßß-0
|
DTSTART:19700101T000000
|
||||||
END:STANDARD
|
END:STANDARD
|
||||||
END:VTIMEZONE
|
END:VTIMEZONE
|
||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
|
@ -1,31 +1,32 @@
|
|||||||
const fetch = require("fetch");
|
const fetch = require("fetch");
|
||||||
const helpers = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
|
|
||||||
describe("App environment", function () {
|
describe("App environment", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/default.js");
|
helpers.startApplication("tests/configs/default.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
afterAll(async function () {
|
afterAll(async () => {
|
||||||
await helpers.stopApplication();
|
await helpers.stopApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("get request from http://localhost:8080 should return 200", function (done) {
|
it("get request from http://localhost:8080 should return 200", (done) => {
|
||||||
fetch("http://localhost:8080").then((res) => {
|
fetch("http://localhost:8080").then((res) => {
|
||||||
|
done();
|
||||||
expect(res.status).toBe(200);
|
expect(res.status).toBe(200);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("get request from http://localhost:8080/nothing should return 404", function (done) {
|
it("get request from http://localhost:8080/nothing should return 404", (done) => {
|
||||||
fetch("http://localhost:8080/nothing").then((res) => {
|
fetch("http://localhost:8080/nothing").then((res) => {
|
||||||
expect(res.status).toBe(404);
|
|
||||||
done();
|
done();
|
||||||
|
expect(res.status).toBe(404);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the title MagicMirror²", function () {
|
it("should show the title MagicMirror²", (done) => {
|
||||||
helpers.waitForElement("title").then((elem) => {
|
helpers.waitForElement("title").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.textContent).toBe("MagicMirror²");
|
expect(elem.textContent).toBe("MagicMirror²");
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const jsdom = require("jsdom");
|
const jsdom = require("jsdom");
|
||||||
|
|
||||||
exports.startApplication = function (configFilename, exec) {
|
exports.startApplication = (configFilename, exec) => {
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
this.stopApplication();
|
this.stopApplication();
|
||||||
// Set config sample for use in test
|
// Set config sample for use in test
|
||||||
@ -14,41 +14,60 @@ exports.startApplication = function (configFilename, exec) {
|
|||||||
global.app.start();
|
global.app.start();
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.stopApplication = async function () {
|
exports.stopApplication = async () => {
|
||||||
if (global.app) {
|
if (global.app) {
|
||||||
global.app.stop();
|
global.app.stop();
|
||||||
}
|
}
|
||||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.getDocument = function (callback) {
|
exports.getDocument = (callback) => {
|
||||||
const url = "http://" + (config.address || "localhost") + ":" + (config.port || "8080");
|
const url = "http://" + (config.address || "localhost") + ":" + (config.port || "8080");
|
||||||
jsdom.JSDOM.fromURL(url, { resources: "usable", runScripts: "dangerously" }).then((dom) => {
|
jsdom.JSDOM.fromURL(url, { resources: "usable", runScripts: "dangerously" }).then((dom) => {
|
||||||
dom.window.name = "jsdom";
|
dom.window.name = "jsdom";
|
||||||
dom.window.onload = function () {
|
dom.window.onload = () => {
|
||||||
global.MutationObserver = dom.window.MutationObserver;
|
|
||||||
global.document = dom.window.document;
|
global.document = dom.window.document;
|
||||||
callback();
|
callback();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.waitForElement = function (selector) {
|
exports.waitForElement = (selector, ignoreValue = "") => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
if (document.querySelector(selector) && document.querySelector(selector).value !== undefined) {
|
let oldVal = "dummy12345";
|
||||||
return resolve(document.querySelector(selector));
|
const interval = setInterval(() => {
|
||||||
|
const element = document.querySelector(selector);
|
||||||
|
if (element) {
|
||||||
|
let newVal = element.textContent;
|
||||||
|
if (newVal === oldVal) {
|
||||||
|
clearInterval(interval);
|
||||||
|
resolve(element);
|
||||||
|
} else {
|
||||||
|
if (ignoreValue === "") {
|
||||||
|
oldVal = newVal;
|
||||||
|
} else {
|
||||||
|
if (!newVal.includes(ignoreValue)) oldVal = newVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
const observer = new MutationObserver(() => {
|
|
||||||
if (document.querySelector(selector) && document.querySelector(selector).value !== undefined) {
|
|
||||||
resolve(document.querySelector(selector));
|
|
||||||
observer.disconnect();
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
}, 100);
|
||||||
observer.observe(document.body, {
|
});
|
||||||
childList: true,
|
};
|
||||||
subtree: true
|
|
||||||
});
|
exports.waitForAllElements = (selector) => {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
let oldVal = 999999;
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
const element = document.querySelectorAll(selector);
|
||||||
|
if (element) {
|
||||||
|
let newVal = element.length;
|
||||||
|
if (newVal === oldVal) {
|
||||||
|
clearInterval(interval);
|
||||||
|
resolve(element);
|
||||||
|
} else {
|
||||||
|
if (newVal !== 0) oldVal = newVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
const helpers = require("../global-setup");
|
const helpers = require("../global-setup");
|
||||||
|
|
||||||
describe("Alert module", function () {
|
describe("Alert module", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/alert/default.js");
|
helpers.startApplication("tests/configs/modules/alert/default.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
afterAll(async function () {
|
afterAll(async () => {
|
||||||
await helpers.stopApplication();
|
await helpers.stopApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the welcome message", function () {
|
it("should show the welcome message", (done) => {
|
||||||
helpers.waitForElement(".ns-box .ns-box-inner .light.bright.small").then((elem) => {
|
helpers.waitForElement(".ns-box .ns-box-inner .light.bright.small").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.textContent).toContain("Welcome, start was successful!");
|
expect(elem.textContent).toContain("Welcome, start was successful!");
|
||||||
});
|
});
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
const helpers = require("../global-setup");
|
const helpers = require("../global-setup");
|
||||||
const serverBasicAuth = require("./basic-auth.js");
|
const serverBasicAuth = require("./basic-auth.js");
|
||||||
|
|
||||||
describe("Calendar module", function () {
|
describe("Calendar module", () => {
|
||||||
/**
|
/**
|
||||||
|
* @param {string} done test done
|
||||||
* @param {string} element css selector
|
* @param {string} element css selector
|
||||||
* @param {string} result expected number
|
* @param {string} result expected number
|
||||||
* @param {string} not reverse result
|
* @param {string} not reverse result
|
||||||
*/
|
*/
|
||||||
function testElementLength(element, result, not) {
|
const testElementLength = (done, element, result, not) => {
|
||||||
helpers.waitForElement(element).then((elem) => {
|
helpers.waitForAllElements(element).then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
if (not === "not") {
|
if (not === "not") {
|
||||||
expect(elem.length).not.toBe(result);
|
expect(elem.length).not.toBe(result);
|
||||||
@ -16,147 +18,148 @@ describe("Calendar module", function () {
|
|||||||
expect(elem.length).toBe(result);
|
expect(elem.length).toBe(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
const testTextContain = function (element, text) {
|
const testTextContain = (done, element, text) => {
|
||||||
helpers.waitForElement(element).then((elem) => {
|
helpers.waitForElement(element, "undefinedLoading").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.textContent).toContain(text);
|
expect(elem.textContent).toContain(text);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
afterAll(async function () {
|
afterAll(async () => {
|
||||||
await helpers.stopApplication();
|
await helpers.stopApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Default configuration", function () {
|
describe("Default configuration", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/calendar/default.js");
|
helpers.startApplication("tests/configs/modules/calendar/default.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the default maximumEntries of 10", () => {
|
it("should show the default maximumEntries of 10", (done) => {
|
||||||
testElementLength(".calendar .event", 10);
|
testElementLength(done, ".calendar .event", 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the default calendar symbol in each event", () => {
|
it("should show the default calendar symbol in each event", (done) => {
|
||||||
testElementLength(".calendar .event .fa-calendar-alt", 0, "not");
|
testElementLength(done, ".calendar .event .fa-calendar-alt", 0, "not");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Custom configuration", function () {
|
describe("Custom configuration", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/calendar/custom.js");
|
helpers.startApplication("tests/configs/modules/calendar/custom.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the custom maximumEntries of 4", () => {
|
it("should show the custom maximumEntries of 4", (done) => {
|
||||||
testElementLength(".calendar .event", 4);
|
testElementLength(done, ".calendar .event", 4);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the custom calendar symbol in each event", () => {
|
it("should show the custom calendar symbol in each event", (done) => {
|
||||||
testElementLength(".calendar .event .fa-birthday-cake", 4);
|
testElementLength(done, ".calendar .event .fa-birthday-cake", 4);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show two custom icons for repeating events", () => {
|
it("should show two custom icons for repeating events", (done) => {
|
||||||
testElementLength(".calendar .event .fa-undo", 2);
|
testElementLength(done, ".calendar .event .fa-undo", 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show two custom icons for day events", () => {
|
it("should show two custom icons for day events", (done) => {
|
||||||
testElementLength(".calendar .event .fa-calendar-day", 2);
|
testElementLength(done, ".calendar .event .fa-calendar-day", 2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Recurring event", function () {
|
describe("Recurring event", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/calendar/recurring.js");
|
helpers.startApplication("tests/configs/modules/calendar/recurring.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the recurring birthday event 6 times", () => {
|
it("should show the recurring birthday event 6 times", (done) => {
|
||||||
testElementLength(".calendar .event", 6);
|
testElementLength(done, ".calendar .event", 6);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
process.setMaxListeners(0);
|
process.setMaxListeners(0);
|
||||||
for (let i = -12; i < 12; i++) {
|
for (let i = -12; i < 12; i++) {
|
||||||
describe("Recurring event per timezone", function () {
|
describe("Recurring event per timezone", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
Date.prototype.getTimezoneOffset = function () {
|
Date.prototype.getTimezoneOffset = () => {
|
||||||
return i * 60;
|
return i * 60;
|
||||||
};
|
};
|
||||||
helpers.startApplication("tests/configs/modules/calendar/recurring.js");
|
helpers.startApplication("tests/configs/modules/calendar/recurring.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain text "Mar 25th" in timezone UTC ' + -i, () => {
|
it('should contain text "Mar 25th" in timezone UTC ' + -i, (done) => {
|
||||||
testTextContain(".calendar", "Mar 25th");
|
testTextContain(done, ".calendar", "Mar 25th");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("Changed port", function () {
|
describe("Changed port", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/calendar/changed-port.js");
|
helpers.startApplication("tests/configs/modules/calendar/changed-port.js");
|
||||||
serverBasicAuth.listen(8010);
|
serverBasicAuth.listen(8010);
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(function (done) {
|
afterAll((done) => {
|
||||||
serverBasicAuth.close(done());
|
serverBasicAuth.close(done());
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return TestEvents", function () {
|
it("should return TestEvents", (done) => {
|
||||||
testElementLength(".calendar .event", 0, "not");
|
testElementLength(done, ".calendar .event", 0, "not");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Basic auth", function () {
|
describe("Basic auth", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/calendar/basic-auth.js");
|
helpers.startApplication("tests/configs/modules/calendar/basic-auth.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return TestEvents", function () {
|
it("should return TestEvents", (done) => {
|
||||||
testElementLength(".calendar .event", 0, "not");
|
testElementLength(done, ".calendar .event", 0, "not");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Basic auth by default", function () {
|
describe("Basic auth by default", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/calendar/auth-default.js");
|
helpers.startApplication("tests/configs/modules/calendar/auth-default.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return TestEvents", function () {
|
it("should return TestEvents", (done) => {
|
||||||
testElementLength(".calendar .event", 0, "not");
|
testElementLength(done, ".calendar .event", 0, "not");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Basic auth backward compatibility configuration: DEPRECATED", function () {
|
describe("Basic auth backward compatibility configuration: DEPRECATED", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/calendar/old-basic-auth.js");
|
helpers.startApplication("tests/configs/modules/calendar/old-basic-auth.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return TestEvents", function () {
|
it("should return TestEvents", (done) => {
|
||||||
testElementLength(".calendar .event", 0, "not");
|
testElementLength(done, ".calendar .event", 0, "not");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Fail Basic auth", function () {
|
describe("Fail Basic auth", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/calendar/fail-basic-auth.js");
|
helpers.startApplication("tests/configs/modules/calendar/fail-basic-auth.js");
|
||||||
serverBasicAuth.listen(8020);
|
serverBasicAuth.listen(8020);
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(function (done) {
|
afterAll((done) => {
|
||||||
serverBasicAuth.close(done());
|
serverBasicAuth.close(done());
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show Unauthorized error", function () {
|
it("should show Unauthorized error", (done) => {
|
||||||
testTextContain(".calendar", "Error in the calendar module. Authorization failed");
|
testTextContain(done, ".calendar", "Error in the calendar module. Authorization failed");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,72 +1,73 @@
|
|||||||
const helpers = require("../global-setup");
|
const helpers = require("../global-setup");
|
||||||
|
|
||||||
describe("Clock set to spanish language module", function () {
|
describe("Clock set to spanish language module", () => {
|
||||||
afterAll(async function () {
|
afterAll(async () => {
|
||||||
await helpers.stopApplication();
|
await helpers.stopApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
const testMatch = function (element, regex) {
|
const testMatch = (done, element, regex) => {
|
||||||
helpers.waitForElement(element).then((elem) => {
|
helpers.waitForElement(element).then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.textContent).toMatch(regex);
|
expect(elem.textContent).toMatch(regex);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
describe("with default 24hr clock config", function () {
|
describe("with default 24hr clock config", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/clock/es/clock_24hr.js");
|
helpers.startApplication("tests/configs/modules/clock/es/clock_24hr.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows date with correct format", function () {
|
it("shows date with correct format", (done) => {
|
||||||
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
|
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
|
||||||
testMatch(".clock .date", dateRegex);
|
testMatch(done, ".clock .date", dateRegex);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows time in 24hr format", function () {
|
it("shows time in 24hr format", (done) => {
|
||||||
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
|
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
|
||||||
testMatch(".clock .time", timeRegex);
|
testMatch(done, ".clock .time", timeRegex);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("with default 12hr clock config", function () {
|
describe("with default 12hr clock config", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/clock/es/clock_12hr.js");
|
helpers.startApplication("tests/configs/modules/clock/es/clock_12hr.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows date with correct format", function () {
|
it("shows date with correct format", (done) => {
|
||||||
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
|
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
|
||||||
testMatch(".clock .date", dateRegex);
|
testMatch(done, ".clock .date", dateRegex);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows time in 12hr format", function () {
|
it("shows time in 12hr format", (done) => {
|
||||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
|
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
|
||||||
testMatch(".clock .time", timeRegex);
|
testMatch(done, ".clock .time", timeRegex);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("with showPeriodUpper config enabled", function () {
|
describe("with showPeriodUpper config enabled", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/clock/es/clock_showPeriodUpper.js");
|
helpers.startApplication("tests/configs/modules/clock/es/clock_showPeriodUpper.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows 12hr time with upper case AM/PM", function () {
|
it("shows 12hr time with upper case AM/PM", (done) => {
|
||||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
|
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
|
||||||
testMatch(".clock .time", timeRegex);
|
testMatch(done, ".clock .time", timeRegex);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("with showWeek config enabled", function () {
|
describe("with showWeek config enabled", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/clock/es/clock_showWeek.js");
|
helpers.startApplication("tests/configs/modules/clock/es/clock_showWeek.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows week with correct format", function () {
|
it("shows week with correct format", (done) => {
|
||||||
const weekRegex = /^Semana [0-9]{1,2}$/;
|
const weekRegex = /^Semana [0-9]{1,2}$/;
|
||||||
testMatch(".clock .week", weekRegex);
|
testMatch(done, ".clock .week", weekRegex);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,118 +1,121 @@
|
|||||||
const helpers = require("../global-setup");
|
const helpers = require("../global-setup");
|
||||||
const moment = require("moment");
|
const moment = require("moment");
|
||||||
|
|
||||||
describe("Clock module", function () {
|
describe("Clock module", () => {
|
||||||
afterAll(async function () {
|
afterAll(async () => {
|
||||||
await helpers.stopApplication();
|
await helpers.stopApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
const testMatch = function (element, regex) {
|
const testMatch = (done, element, regex) => {
|
||||||
helpers.waitForElement(element).then((elem) => {
|
helpers.waitForElement(element).then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.textContent).toMatch(regex);
|
expect(elem.textContent).toMatch(regex);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
describe("with default 24hr clock config", function () {
|
describe("with default 24hr clock config", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/clock/clock_24hr.js");
|
helpers.startApplication("tests/configs/modules/clock/clock_24hr.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the date in the correct format", function () {
|
it("should show the date in the correct format", (done) => {
|
||||||
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}$/;
|
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);
|
testMatch(done, ".clock .date", dateRegex);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the time in 24hr format", function () {
|
it("should show the time in 24hr format", (done) => {
|
||||||
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
|
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
|
||||||
testMatch(".clock .time", timeRegex);
|
testMatch(done, ".clock .time", timeRegex);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("with default 12hr clock config", function () {
|
describe("with default 12hr clock config", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/clock/clock_12hr.js");
|
helpers.startApplication("tests/configs/modules/clock/clock_12hr.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the date in the correct format", function () {
|
it("should show the date in the correct format", (done) => {
|
||||||
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}$/;
|
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);
|
testMatch(done, ".clock .date", dateRegex);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the time in 12hr format", function () {
|
it("should show the time in 12hr format", (done) => {
|
||||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
|
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
|
||||||
testMatch(".clock .time", timeRegex);
|
testMatch(done, ".clock .time", timeRegex);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("with showPeriodUpper config enabled", function () {
|
describe("with showPeriodUpper config enabled", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/clock/clock_showPeriodUpper.js");
|
helpers.startApplication("tests/configs/modules/clock/clock_showPeriodUpper.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show 12hr time with upper case AM/PM", function () {
|
it("should show 12hr time with upper case AM/PM", (done) => {
|
||||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
|
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
|
||||||
testMatch(".clock .time", timeRegex);
|
testMatch(done, ".clock .time", timeRegex);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("with displaySeconds config disabled", function () {
|
describe("with displaySeconds config disabled", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/clock/clock_displaySeconds_false.js");
|
helpers.startApplication("tests/configs/modules/clock/clock_displaySeconds_false.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show 12hr time without seconds am/pm", function () {
|
it("should show 12hr time without seconds am/pm", (done) => {
|
||||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/;
|
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/;
|
||||||
testMatch(".clock .time", timeRegex);
|
testMatch(done, ".clock .time", timeRegex);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("with showTime config disabled", function () {
|
describe("with showTime config disabled", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/clock/clock_showTime.js");
|
helpers.startApplication("tests/configs/modules/clock/clock_showTime.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show not show the time when digital clock is shown", function () {
|
it("should not show the time when digital clock is shown", (done) => {
|
||||||
helpers.waitForElement(".clock .digital .time").then((elem) => {
|
const elem = document.querySelector(".clock .digital .time");
|
||||||
|
done();
|
||||||
expect(elem).toBe(null);
|
expect(elem).toBe(null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe("with showWeek config enabled", function () {
|
describe("with showWeek config enabled", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/clock/clock_showWeek.js");
|
helpers.startApplication("tests/configs/modules/clock/clock_showWeek.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the week in the correct format", function () {
|
it("should show the week in the correct format", (done) => {
|
||||||
const weekRegex = /^Week [0-9]{1,2}$/;
|
const weekRegex = /^Week [0-9]{1,2}$/;
|
||||||
testMatch(".clock .week", weekRegex);
|
testMatch(done, ".clock .week", weekRegex);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the week with the correct number of week of year", function () {
|
it("should show the week with the correct number of week of year", (done) => {
|
||||||
const currentWeekNumber = moment().week();
|
const currentWeekNumber = moment().week();
|
||||||
const weekToShow = "Week " + currentWeekNumber;
|
const weekToShow = "Week " + currentWeekNumber;
|
||||||
helpers.waitForElement(".clock .week").then((elem) => {
|
helpers.waitForElement(".clock .week").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.textContent).toBe(weekToShow);
|
expect(elem.textContent).toBe(weekToShow);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("with analog clock face enabled", function () {
|
describe("with analog clock face enabled", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/clock/clock_analog.js");
|
helpers.startApplication("tests/configs/modules/clock/clock_analog.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the analog clock face", () => {
|
it("should show the analog clock face", (done) => {
|
||||||
helpers.waitForElement(".clockCircle").then((elem) => {
|
helpers.waitForElement(".clockCircle").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -3,87 +3,95 @@ const helpers = require("../global-setup");
|
|||||||
/**
|
/**
|
||||||
* move similar tests in function doTest
|
* move similar tests in function doTest
|
||||||
*
|
*
|
||||||
|
* @param {string} done test done
|
||||||
* @param {Array} complimentsArray The array of compliments.
|
* @param {Array} complimentsArray The array of compliments.
|
||||||
*/
|
*/
|
||||||
function doTest(complimentsArray) {
|
const doTest = (done, complimentsArray) => {
|
||||||
helpers.waitForElement(".compliments").then((elem) => {
|
helpers.waitForElement(".compliments").then((elem) => {
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
helpers.waitForElement(".module-content").then((elem) => {
|
helpers.waitForElement(".module-content").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(complimentsArray).toContain(elem.textContent);
|
expect(complimentsArray).toContain(elem.textContent);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
describe("Compliments module", function () {
|
describe("Compliments module", () => {
|
||||||
afterAll(async function () {
|
afterAll(async () => {
|
||||||
await helpers.stopApplication();
|
await helpers.stopApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("parts of days", function () {
|
describe("parts of days", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js");
|
helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if Morning compliments for that part of day", function () {
|
it("if Morning compliments for that part of day", (done) => {
|
||||||
const hour = new Date().getHours();
|
const hour = new Date().getHours();
|
||||||
if (hour >= 3 && hour < 12) {
|
if (hour >= 3 && hour < 12) {
|
||||||
// if morning check
|
// if morning check
|
||||||
doTest(["Hi", "Good Morning", "Morning test"]);
|
doTest(done, ["Hi", "Good Morning", "Morning test"]);
|
||||||
|
} else {
|
||||||
|
done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if Afternoon show Compliments for that part of day", function () {
|
it("if Afternoon show Compliments for that part of day", (done) => {
|
||||||
const hour = new Date().getHours();
|
const hour = new Date().getHours();
|
||||||
if (hour >= 12 && hour < 17) {
|
if (hour >= 12 && hour < 17) {
|
||||||
// if afternoon check
|
// if afternoon check
|
||||||
doTest(["Hello", "Good Afternoon", "Afternoon test"]);
|
doTest(done, ["Hello", "Good Afternoon", "Afternoon test"]);
|
||||||
|
} else {
|
||||||
|
done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if Evening show Compliments for that part of day", function () {
|
it("if Evening show Compliments for that part of day", (done) => {
|
||||||
const hour = new Date().getHours();
|
const hour = new Date().getHours();
|
||||||
if (!(hour >= 3 && hour < 12) && !(hour >= 12 && hour < 17)) {
|
if (!(hour >= 3 && hour < 12) && !(hour >= 12 && hour < 17)) {
|
||||||
// if evening check
|
// if evening check
|
||||||
doTest(["Hello There", "Good Evening", "Evening test"]);
|
doTest(done, ["Hello There", "Good Evening", "Evening test"]);
|
||||||
|
} else {
|
||||||
|
done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Feature anytime in compliments module", function () {
|
describe("Feature anytime in compliments module", () => {
|
||||||
describe("Set anytime and empty compliments for morning, evening and afternoon ", function () {
|
describe("Set anytime and empty compliments for morning, evening and afternoon ", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/compliments/compliments_anytime.js");
|
helpers.startApplication("tests/configs/modules/compliments/compliments_anytime.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Show anytime because if configure empty parts of day compliments and set anytime compliments", function () {
|
it("Show anytime because if configure empty parts of day compliments and set anytime compliments", (done) => {
|
||||||
doTest(["Anytime here"]);
|
doTest(done, ["Anytime here"]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Only anytime present in configuration compliments", function () {
|
describe("Only anytime present in configuration compliments", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/compliments/compliments_only_anytime.js");
|
helpers.startApplication("tests/configs/modules/compliments/compliments_only_anytime.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Show anytime compliments", function () {
|
it("Show anytime compliments", (done) => {
|
||||||
doTest(["Anytime here"]);
|
doTest(done, ["Anytime here"]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Feature date in compliments module", function () {
|
describe("Feature date in compliments module", () => {
|
||||||
describe("Set date and empty compliments for anytime, morning, evening and afternoon", function () {
|
describe("Set date and empty compliments for anytime, morning, evening and afternoon", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/compliments/compliments_date.js");
|
helpers.startApplication("tests/configs/modules/compliments/compliments_date.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Show happy new year compliment on new years day", function () {
|
it("Show happy new year compliment on new years day", (done) => {
|
||||||
doTest(["Happy new year!"]);
|
doTest(done, ["Happy new year!"]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,32 +1,34 @@
|
|||||||
const helpers = require("../global-setup");
|
const helpers = require("../global-setup");
|
||||||
|
|
||||||
describe("Test helloworld module", function () {
|
describe("Test helloworld module", () => {
|
||||||
afterAll(async function () {
|
afterAll(async () => {
|
||||||
await helpers.stopApplication();
|
await helpers.stopApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("helloworld set config text", function () {
|
describe("helloworld set config text", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/helloworld/helloworld.js");
|
helpers.startApplication("tests/configs/modules/helloworld/helloworld.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Test message helloworld module", function () {
|
it("Test message helloworld module", (done) => {
|
||||||
helpers.waitForElement(".helloworld").then((elem) => {
|
helpers.waitForElement(".helloworld").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.textContent).toContain("Test HelloWorld Module");
|
expect(elem.textContent).toContain("Test HelloWorld Module");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("helloworld default config text", function () {
|
describe("helloworld default config text", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/helloworld/helloworld_default.js");
|
helpers.startApplication("tests/configs/modules/helloworld/helloworld_default.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Test message helloworld module", function () {
|
it("Test message helloworld module", (done) => {
|
||||||
helpers.waitForElement(".helloworld").then((elem) => {
|
helpers.waitForElement(".helloworld").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.textContent).toContain("Hello World!");
|
expect(elem.textContent).toContain("Hello World!");
|
||||||
});
|
});
|
||||||
|
@ -1,80 +1,88 @@
|
|||||||
const helpers = require("../global-setup");
|
const helpers = require("../global-setup");
|
||||||
|
|
||||||
describe("Newsfeed module", function () {
|
describe("Newsfeed module", () => {
|
||||||
afterAll(async function () {
|
afterAll(async () => {
|
||||||
await helpers.stopApplication();
|
await helpers.stopApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Default configuration", function () {
|
describe("Default configuration", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/newsfeed/default.js");
|
helpers.startApplication("tests/configs/modules/newsfeed/default.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the newsfeed title", function () {
|
it("should show the newsfeed title", (done) => {
|
||||||
helpers.waitForElement(".newsfeed .newsfeed-source").then((elem) => {
|
helpers.waitForElement(".newsfeed .newsfeed-source").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.textContent).toContain("Rodrigo Ramirez Blog");
|
expect(elem.textContent).toContain("Rodrigo Ramirez Blog");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the newsfeed article", function () {
|
it("should show the newsfeed article", (done) => {
|
||||||
helpers.waitForElement(".newsfeed .newsfeed-title").then((elem) => {
|
helpers.waitForElement(".newsfeed .newsfeed-title").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.textContent).toContain("QPanel");
|
expect(elem.textContent).toContain("QPanel");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should NOT show the newsfeed description", () => {
|
it("should NOT show the newsfeed description", (done) => {
|
||||||
helpers.waitForElement(".newsfeed .newsfeed-desc").then((elem) => {
|
helpers.waitForElement(".newsfeed").then((elem) => {
|
||||||
expect(elem).toBe(null);
|
const element = document.querySelector(".newsfeed .newsfeed-desc");
|
||||||
|
done();
|
||||||
|
expect(element).toBe(null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Custom configuration", function () {
|
describe("Custom configuration", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/newsfeed/prohibited_words.js");
|
helpers.startApplication("tests/configs/modules/newsfeed/prohibited_words.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not show articles with prohibited words", function () {
|
it("should not show articles with prohibited words", (done) => {
|
||||||
helpers.waitForElement(".newsfeed .newsfeed-title").then((elem) => {
|
helpers.waitForElement(".newsfeed .newsfeed-title").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.textContent).toContain("Problema VirtualBox");
|
expect(elem.textContent).toContain("Problema VirtualBox");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the newsfeed description", () => {
|
it("should show the newsfeed description", (done) => {
|
||||||
helpers.waitForElement(".newsfeed .newsfeed-desc").then((elem) => {
|
helpers.waitForElement(".newsfeed .newsfeed-desc").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.textContent.length).not.toBe(0);
|
expect(elem.textContent.length).not.toBe(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Invalid configuration", function () {
|
describe("Invalid configuration", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/newsfeed/incorrect_url.js");
|
helpers.startApplication("tests/configs/modules/newsfeed/incorrect_url.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show malformed url warning", function () {
|
it("should show malformed url warning", (done) => {
|
||||||
helpers.waitForElement(".newsfeed .small").then((elem) => {
|
helpers.waitForElement(".newsfeed .small", "No news at the moment.").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.textContent).toContain("Error in the Newsfeed module. Malformed url.");
|
expect(elem.textContent).toContain("Error in the Newsfeed module. Malformed url.");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Ignore items", function () {
|
describe("Ignore items", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/newsfeed/ignore_items.js");
|
helpers.startApplication("tests/configs/modules/newsfeed/ignore_items.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show empty items info message", function () {
|
it("should show empty items info message", (done) => {
|
||||||
helpers.waitForElement(".newsfeed .small").then((elem) => {
|
helpers.waitForElement(".newsfeed .small").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.textContent).toContain("No news at the moment.");
|
expect(elem.textContent).toContain("No news at the moment.");
|
||||||
});
|
});
|
||||||
|
@ -4,13 +4,15 @@ const path = require("path");
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const { generateWeather, generateWeatherForecast } = require("./mocks");
|
const { generateWeather, generateWeatherForecast } = require("./mocks");
|
||||||
|
|
||||||
describe("Weather module", function () {
|
describe("Weather module", () => {
|
||||||
/**
|
/**
|
||||||
|
* @param {string} done test done
|
||||||
* @param {string} element css selector
|
* @param {string} element css selector
|
||||||
* @param {string} result Expected text in given selector
|
* @param {string} result Expected text in given selector
|
||||||
*/
|
*/
|
||||||
function getText(element, result) {
|
const getText = (done, element, result) => {
|
||||||
helpers.waitForElement(element).then((elem) => {
|
helpers.waitForElement(element).then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(
|
expect(
|
||||||
elem.textContent
|
elem.textContent
|
||||||
@ -19,14 +21,14 @@ describe("Weather module", function () {
|
|||||||
.replace(/[ ]+/g, " ")
|
.replace(/[ ]+/g, " ")
|
||||||
).toBe(result);
|
).toBe(result);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} configFile path to configuration file
|
* @param {string} configFile path to configuration file
|
||||||
* @param {string} additionalMockData special data for mocking
|
* @param {string} additionalMockData special data for mocking
|
||||||
* @param {string} callback callback
|
* @param {string} callback callback
|
||||||
*/
|
*/
|
||||||
function startApp(configFile, additionalMockData, callback) {
|
const startApp = (configFile, additionalMockData, callback) => {
|
||||||
let mockWeather;
|
let mockWeather;
|
||||||
if (configFile.includes("forecast")) {
|
if (configFile.includes("forecast")) {
|
||||||
mockWeather = generateWeatherForecast(additionalMockData);
|
mockWeather = generateWeatherForecast(additionalMockData);
|
||||||
@ -38,94 +40,98 @@ describe("Weather module", function () {
|
|||||||
fs.writeFileSync(path.resolve(__dirname + "../../../../config/config.js"), content);
|
fs.writeFileSync(path.resolve(__dirname + "../../../../config/config.js"), content);
|
||||||
helpers.startApplication("");
|
helpers.startApplication("");
|
||||||
helpers.getDocument(callback);
|
helpers.getDocument(callback);
|
||||||
}
|
};
|
||||||
|
|
||||||
afterAll(async function () {
|
afterAll(async () => {
|
||||||
await helpers.stopApplication();
|
await helpers.stopApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Current weather", function () {
|
describe("Current weather", () => {
|
||||||
describe("Default configuration", function () {
|
describe("Default configuration", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
startApp("tests/configs/modules/weather/currentweather_default.js", {}, done);
|
startApp("tests/configs/modules/weather/currentweather_default.js", {}, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render wind speed and wind direction", function () {
|
it("should render wind speed and wind direction", (done) => {
|
||||||
getText(".weather .normal.medium span:nth-child(2)", "6 WSW");
|
getText(done, ".weather .normal.medium span:nth-child(2)", "6 WSW"); // now "12"
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render temperature with icon", function () {
|
it("should render temperature with icon", (done) => {
|
||||||
getText(".weather .large.light span.bright", "1.5°");
|
getText(done, ".weather .large.light span.bright", "1.5°"); // now "1°C"
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render feels like temperature", function () {
|
it("should render feels like temperature", (done) => {
|
||||||
getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -5.6°");
|
getText(done, ".weather .normal.medium.feelslike span.dimmed", "Feels like -5.6°"); // now "Feels like -6°C"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Default configuration with sunrise", function () {
|
describe("Default configuration with sunrise", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
const sunrise = moment().startOf("day").unix();
|
const sunrise = moment().startOf("day").unix();
|
||||||
const sunset = moment().startOf("day").unix();
|
const sunset = moment().startOf("day").unix();
|
||||||
startApp("tests/configs/modules/weather/currentweather_default.js", { sys: { sunrise, sunset } }, done);
|
startApp("tests/configs/modules/weather/currentweather_default.js", { sys: { sunrise, sunset } }, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render sunrise", function () {
|
it("should render sunrise", (done) => {
|
||||||
getText(".weather .normal.medium span:nth-child(4)", "12:00 am");
|
getText(done, ".weather .normal.medium span:nth-child(4)", "12:00 am");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Default configuration with sunset", function () {
|
describe("Default configuration with sunset", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
const sunrise = moment().startOf("day").unix();
|
const sunrise = moment().startOf("day").unix();
|
||||||
const sunset = moment().endOf("day").unix();
|
const sunset = moment().endOf("day").unix();
|
||||||
startApp("tests/configs/modules/weather/currentweather_default.js", { sys: { sunrise, sunset } }, done);
|
startApp("tests/configs/modules/weather/currentweather_default.js", { sys: { sunrise, sunset } }, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render sunset", function () {
|
it("should render sunset", (done) => {
|
||||||
getText(".weather .normal.medium span:nth-child(4)", "11:59 pm");
|
getText(done, ".weather .normal.medium span:nth-child(4)", "11:59 pm");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Compliments Integration", function () {
|
describe("Compliments Integration", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
startApp("tests/configs/modules/weather/currentweather_compliments.js", {}, done);
|
startApp("tests/configs/modules/weather/currentweather_compliments.js", {}, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render a compliment based on the current weather", function () {
|
it("should render a compliment based on the current weather", (done) => {
|
||||||
getText(".compliments .module-content span", "snow");
|
getText(done, ".compliments .module-content span", "snow");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Configuration Options", function () {
|
describe("Configuration Options", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
startApp("tests/configs/modules/weather/currentweather_options.js", {}, done);
|
startApp("tests/configs/modules/weather/currentweather_options.js", {}, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render useBeaufort = false", function () {
|
it("should render useBeaufort = false", (done) => {
|
||||||
getText(".weather .normal.medium span:nth-child(2)", "12");
|
getText(done, ".weather .normal.medium span:nth-child(2)", "12");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render showWindDirectionAsArrow = true", function () {
|
it("should render showWindDirectionAsArrow = true", (done) => {
|
||||||
helpers.waitForElement(".weather .normal.medium sup i.fa-long-arrow-alt-up").then((elem) => {
|
helpers.waitForElement(".weather .normal.medium sup i.fa-long-arrow-alt-up").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.outerHTML).toContain("transform:rotate(250deg);");
|
expect(elem.outerHTML).toContain("transform:rotate(250deg);");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render showHumidity = true", function () {
|
it("should render showHumidity = true", (done) => {
|
||||||
getText(".weather .normal.medium span:nth-child(3)", "93.7");
|
getText(done, ".weather .normal.medium span:nth-child(3)", "93.7");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render degreeLabel = true", function () {
|
it("should render degreeLabel = true for temp", (done) => {
|
||||||
getText(".weather .large.light span.bright", "1°C");
|
getText(done, ".weather .large.light span.bright", "1°C");
|
||||||
getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -6°C");
|
});
|
||||||
|
|
||||||
|
it("should render degreeLabel = true for feels like", (done) => {
|
||||||
|
getText(done, ".weather .normal.medium.feelslike span.dimmed", "Feels like -6°C");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Current weather units", function () {
|
describe("Current weather units", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
startApp(
|
startApp(
|
||||||
"tests/configs/modules/weather/currentweather_units.js",
|
"tests/configs/modules/weather/currentweather_units.js",
|
||||||
{
|
{
|
||||||
@ -142,98 +148,108 @@ describe("Weather module", function () {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render imperial units", function () {
|
it("should render imperial units for wind", (done) => {
|
||||||
getText(".weather .normal.medium span:nth-child(2)", "6 WSW");
|
getText(done, ".weather .normal.medium span:nth-child(2)", "6 WSW");
|
||||||
getText(".weather .large.light span.bright", "34,7°");
|
|
||||||
getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render custom decimalSymbol = ','", function () {
|
it("should render imperial units for temp", (done) => {
|
||||||
getText(".weather .normal.medium span:nth-child(3)", "93,7");
|
getText(done, ".weather .large.light span.bright", "34,7°");
|
||||||
getText(".weather .large.light span.bright", "34,7°");
|
});
|
||||||
getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°");
|
|
||||||
|
it("should render imperial units for feels like", (done) => {
|
||||||
|
getText(done, ".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should render custom decimalSymbol = ',' for humidity", (done) => {
|
||||||
|
getText(done, ".weather .normal.medium span:nth-child(3)", "93,7");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should render custom decimalSymbol = ',' for temp", (done) => {
|
||||||
|
getText(done, ".weather .large.light span.bright", "34,7°");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should render custom decimalSymbol = ',' for feels like", (done) => {
|
||||||
|
getText(done, ".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Weather Forecast", function () {
|
describe("Weather Forecast", () => {
|
||||||
describe("Default configuration", function () {
|
describe("Default configuration", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
startApp("tests/configs/modules/weather/forecastweather_default.js", {}, done);
|
startApp("tests/configs/modules/weather/forecastweather_default.js", {}, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render days", function () {
|
|
||||||
const days = ["Today", "Tomorrow", "Sun", "Mon", "Tue"];
|
const days = ["Today", "Tomorrow", "Sun", "Mon", "Tue"];
|
||||||
|
|
||||||
for (const [index, day] of days.entries()) {
|
for (const [index, day] of days.entries()) {
|
||||||
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day);
|
it("should render day " + day, (done) => {
|
||||||
}
|
getText(done, `.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
it("should render icons", function () {
|
|
||||||
const icons = ["day-cloudy", "rain", "day-sunny", "day-sunny", "day-sunny"];
|
const icons = ["day-cloudy", "rain", "day-sunny", "day-sunny", "day-sunny"];
|
||||||
|
|
||||||
for (const [index, icon] of icons.entries()) {
|
for (const [index, icon] of icons.entries()) {
|
||||||
|
it("should render icon " + icon, (done) => {
|
||||||
helpers.waitForElement(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(2) span.wi-${icon}`).then((elem) => {
|
helpers.waitForElement(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(2) span.wi-${icon}`).then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render max temperatures", function () {
|
|
||||||
const temperatures = ["24.4°", "21.0°", "22.9°", "23.4°", "20.6°"];
|
|
||||||
|
|
||||||
for (const [index, temp] of temperatures.entries()) {
|
|
||||||
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const maxTemps = ["24.4°", "21.0°", "22.9°", "23.4°", "20.6°"];
|
||||||
|
for (const [index, temp] of maxTemps.entries()) {
|
||||||
|
it("should render max temperature " + temp, (done) => {
|
||||||
|
getText(done, `.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const minTemps = ["15.3°", "13.6°", "13.8°", "13.9°", "10.9°"];
|
||||||
|
for (const [index, temp] of minTemps.entries()) {
|
||||||
|
it("should render min temperature " + temp, (done) => {
|
||||||
|
getText(done, `.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render min temperatures", function () {
|
|
||||||
const temperatures = ["15.3°", "13.6°", "13.8°", "13.9°", "10.9°"];
|
|
||||||
|
|
||||||
for (const [index, temp] of temperatures.entries()) {
|
|
||||||
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
it("should render fading of rows", function () {
|
|
||||||
const opacities = [1, 1, 0.8, 0.5333333333333333, 0.2666666666666667];
|
const opacities = [1, 1, 0.8, 0.5333333333333333, 0.2666666666666667];
|
||||||
|
|
||||||
for (const [index, opacity] of opacities.entries()) {
|
for (const [index, opacity] of opacities.entries()) {
|
||||||
|
it("should render fading of rows with opacity=" + opacity, (done) => {
|
||||||
helpers.waitForElement(`.weather table.small tr:nth-child(${index + 1})`).then((elem) => {
|
helpers.waitForElement(`.weather table.small tr:nth-child(${index + 1})`).then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.outerHTML).toContain(`<tr style="opacity: ${opacity};">`);
|
expect(elem.outerHTML).toContain(`<tr style="opacity: ${opacity};">`);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe("Absolute configuration", function () {
|
describe("Absolute configuration", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
startApp("tests/configs/modules/weather/forecastweather_absolute.js", {}, done);
|
startApp("tests/configs/modules/weather/forecastweather_absolute.js", {}, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render days", function () {
|
|
||||||
const days = ["Fri", "Sat", "Sun", "Mon", "Tue"];
|
const days = ["Fri", "Sat", "Sun", "Mon", "Tue"];
|
||||||
|
|
||||||
for (const [index, day] of days.entries()) {
|
for (const [index, day] of days.entries()) {
|
||||||
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day);
|
it("should render day " + day, (done) => {
|
||||||
|
getText(done, `.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe("Configuration Options", function () {
|
describe("Configuration Options", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
startApp("tests/configs/modules/weather/forecastweather_options.js", {}, done);
|
startApp("tests/configs/modules/weather/forecastweather_options.js", {}, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render custom table class", function () {
|
it("should render custom table class", (done) => {
|
||||||
helpers.waitForElement(".weather table.myTableClass").then((elem) => {
|
helpers.waitForElement(".weather table.myTableClass").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render colored rows", function () {
|
it("should render colored rows", (done) => {
|
||||||
helpers.waitForElement(".weather table.myTableClass").then((table) => {
|
helpers.waitForElement(".weather table.myTableClass").then((table) => {
|
||||||
|
done();
|
||||||
expect(table).not.toBe(null);
|
expect(table).not.toBe(null);
|
||||||
expect(table.rows).not.toBe(null);
|
expect(table.rows).not.toBe(null);
|
||||||
expect(table.rows.length).toBe(5);
|
expect(table.rows.length).toBe(5);
|
||||||
@ -241,18 +257,17 @@ describe("Weather module", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Forecast weather units", function () {
|
describe("Forecast weather units", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
startApp("tests/configs/modules/weather/forecastweather_units.js", {}, done);
|
startApp("tests/configs/modules/weather/forecastweather_units.js", {}, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render custom decimalSymbol = '_'", function () {
|
|
||||||
const temperatures = ["24_4°", "21_0°", "22_9°", "23_4°", "20_6°"];
|
const temperatures = ["24_4°", "21_0°", "22_9°", "23_4°", "20_6°"];
|
||||||
|
|
||||||
for (const [index, temp] of temperatures.entries()) {
|
for (const [index, temp] of temperatures.entries()) {
|
||||||
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp);
|
it("should render custom decimalSymbol = '_' for temp " + temp, (done) => {
|
||||||
|
getText(done, `.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -1,24 +1,26 @@
|
|||||||
const helpers = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
|
|
||||||
describe("Display of modules", function () {
|
describe("Display of modules", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll(function (done) {
|
||||||
helpers.startApplication("tests/configs/modules/display.js");
|
helpers.startApplication("tests/configs/modules/display.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
afterAll(async function () {
|
afterAll(async () => {
|
||||||
await helpers.stopApplication();
|
await helpers.stopApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the test header", function () {
|
it("should show the test header", (done) => {
|
||||||
helpers.waitForElement("#module_0_helloworld .module-header").then((elem) => {
|
helpers.waitForElement("#module_0_helloworld .module-header").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
// textContent gibt hier lowercase zurück, das uppercase wird durch css realisiert, was daher nicht in textContent landet
|
// textContent gibt hier lowercase zurück, das uppercase wird durch css realisiert, was daher nicht in textContent landet
|
||||||
expect(elem.textContent).toBe("test_header");
|
expect(elem.textContent).toBe("test_header");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show no header if no header text is specified", function () {
|
it("should show no header if no header text is specified", (done) => {
|
||||||
helpers.waitForElement("#module_1_helloworld .module-header").then((elem) => {
|
helpers.waitForElement("#module_1_helloworld .module-header").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.textContent).toBe("undefined");
|
expect(elem.textContent).toBe("undefined");
|
||||||
});
|
});
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
const helpers = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
|
|
||||||
describe("Position of modules", function () {
|
describe("Position of modules", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/modules/positions.js");
|
helpers.startApplication("tests/configs/modules/positions.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
afterAll(async function () {
|
afterAll(async () => {
|
||||||
await helpers.stopApplication();
|
await helpers.stopApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -13,8 +13,9 @@ describe("Position of modules", function () {
|
|||||||
|
|
||||||
for (const position of positions) {
|
for (const position of positions) {
|
||||||
const className = position.replace("_", ".");
|
const className = position.replace("_", ".");
|
||||||
it("should show text in " + position, function () {
|
it("should show text in " + position, (done) => {
|
||||||
helpers.waitForElement("." + className).then((elem) => {
|
helpers.waitForElement("." + className).then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.textContent).toContain("Text in " + position);
|
expect(elem.textContent).toContain("Text in " + position);
|
||||||
});
|
});
|
||||||
|
@ -1,23 +1,25 @@
|
|||||||
const helpers = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
|
|
||||||
describe("Check configuration without modules", function () {
|
describe("Check configuration without modules", () => {
|
||||||
beforeAll(function (done) {
|
beforeAll((done) => {
|
||||||
helpers.startApplication("tests/configs/without_modules.js");
|
helpers.startApplication("tests/configs/without_modules.js");
|
||||||
helpers.getDocument(done);
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
afterAll(async function () {
|
afterAll(async () => {
|
||||||
await helpers.stopApplication();
|
await helpers.stopApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Show the message MagicMirror² title", function () {
|
it("Show the message MagicMirror² title", (done) => {
|
||||||
helpers.waitForElement("#module_1_helloworld .module-content").then((elem) => {
|
helpers.waitForElement("#module_1_helloworld .module-content").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.textContent).toContain("MagicMirror²");
|
expect(elem.textContent).toContain("MagicMirror²");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Show the text Michael's website", function () {
|
it("Show the text Michael's website", (done) => {
|
||||||
helpers.waitForElement("#module_5_helloworld .module-content").then((elem) => {
|
helpers.waitForElement("#module_5_helloworld .module-content").then((elem) => {
|
||||||
|
done();
|
||||||
expect(elem).not.toBe(null);
|
expect(elem).not.toBe(null);
|
||||||
expect(elem.textContent).toContain("www.michaelteeuw.nl");
|
expect(elem.textContent).toContain("www.michaelteeuw.nl");
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user