mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
update modules alert and compliments
This commit is contained in:
84
tests/e2e/compliments_spec.js
Normal file
84
tests/e2e/compliments_spec.js
Normal file
@@ -0,0 +1,84 @@
|
||||
const helpers = require("../global-setup");
|
||||
let app = null;
|
||||
|
||||
doTest = function (complimentsArray) {
|
||||
let elem = document.querySelector(".compliments");
|
||||
expect(elem).not.toBe(null);
|
||||
elem = document.querySelector(".module-content");
|
||||
expect(elem).not.toBe(null);
|
||||
expect(complimentsArray).toContain(elem.textContent);
|
||||
};
|
||||
|
||||
describe("Compliments module", function () {
|
||||
afterAll(function () {
|
||||
helpers.stopApplication(app);
|
||||
});
|
||||
|
||||
describe("parts of days", function () {
|
||||
beforeAll(function (done) {
|
||||
app = helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js");
|
||||
helpers.getDocument(done, 1000);
|
||||
});
|
||||
|
||||
it("if Morning compliments for that part of day", function () {
|
||||
const hour = new Date().getHours();
|
||||
if (hour >= 3 && hour < 12) {
|
||||
// if morning check
|
||||
doTest(["Hi", "Good Morning", "Morning test"]);
|
||||
}
|
||||
});
|
||||
|
||||
it("if Afternoon show Compliments for that part of day", function () {
|
||||
const hour = new Date().getHours();
|
||||
if (hour >= 12 && hour < 17) {
|
||||
// if afternoon check
|
||||
doTest(["Hello", "Good Afternoon", "Afternoon test"]);
|
||||
}
|
||||
});
|
||||
|
||||
it("if Evening show Compliments for that part of day", function () {
|
||||
const hour = new Date().getHours();
|
||||
if (!(hour >= 3 && hour < 12) && !(hour >= 12 && hour < 17)) {
|
||||
// if evening check
|
||||
doTest(["Hello There", "Good Evening", "Evening test"]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("Feature anytime in compliments module", function () {
|
||||
describe("Set anytime and empty compliments for morning, evening and afternoon ", function () {
|
||||
beforeAll(function (done) {
|
||||
app = helpers.startApplication("tests/configs/modules/compliments/compliments_anytime.js");
|
||||
helpers.getDocument(done, 1000);
|
||||
});
|
||||
|
||||
it("Show anytime because if configure empty parts of day compliments and set anytime compliments", async function () {
|
||||
doTest(["Anytime here"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Only anytime present in configuration compliments", function () {
|
||||
beforeAll(function (done) {
|
||||
app = helpers.startApplication("tests/configs/modules/compliments/compliments_only_anytime.js");
|
||||
helpers.getDocument(done, 1000);
|
||||
});
|
||||
|
||||
it("Show anytime compliments", async function () {
|
||||
doTest(["Anytime here"]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Feature date in compliments module", function () {
|
||||
describe("Set date and empty compliments for anytime, morning, evening and afternoon", function () {
|
||||
beforeAll(function (done) {
|
||||
app = helpers.startApplication("tests/configs/modules/compliments/compliments_date.js");
|
||||
helpers.getDocument(done, 1000);
|
||||
});
|
||||
|
||||
it("Show happy new year compliment on new years day", async function () {
|
||||
doTest(["Happy new year!"]);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@@ -3,12 +3,16 @@ const config = require("../configs/empty_ipWhiteList");
|
||||
|
||||
exports.startApplication = function (configFilename, exec) {
|
||||
jest.resetModules();
|
||||
let app = global.app;
|
||||
if (app) {
|
||||
app.stop();
|
||||
}
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = configFilename;
|
||||
if (exec) exec;
|
||||
const app = require("app.js");
|
||||
app = require("app.js");
|
||||
app.start();
|
||||
|
||||
global.app = app;
|
||||
return app;
|
||||
};
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
* @param {string} err The error message.
|
||||
*/
|
||||
function myError(err) {
|
||||
if (err.includes("ECONNREFUSED") || err.includes("ECONNRESET") || err.includes("socket hang up")) {
|
||||
if (err.includes("ECONNREFUSED") || err.includes("ECONNRESET") || err.includes("socket hang up") || err.includes("exports is not defined")) {
|
||||
jest.fn();
|
||||
} else {
|
||||
console.dir(err);
|
||||
|
18
tests/e2e/modules/alert_spec.js
Normal file
18
tests/e2e/modules/alert_spec.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const helpers = require("../global-setup");
|
||||
let app = null;
|
||||
|
||||
describe("Alert module", function () {
|
||||
beforeAll(function (done) {
|
||||
app = helpers.startApplication("tests/configs/modules/alert/default.js");
|
||||
helpers.getDocument(done, 1000);
|
||||
});
|
||||
afterAll(function () {
|
||||
helpers.stopApplication(app);
|
||||
});
|
||||
|
||||
it("should show the welcome message", function () {
|
||||
const elem = document.querySelector(".ns-box .ns-box-inner .light.bright.small");
|
||||
expect(elem).not.toBe(null);
|
||||
expect(elem.textContent).toContain("Welcome, start was successful!");
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user