Files
MagicMirror/tests/e2e/modules/compliments_spec.js
T

93 lines
3.0 KiB
JavaScript
Raw Normal View History

2023-01-01 18:09:08 +01:00
const helpers = require("../helpers/global-setup");
2021-09-25 23:37:37 +02:00
2023-01-01 18:09:08 +01:00
describe("Compliments module", () => {
2024-01-01 15:38:08 +01:00
2023-01-01 18:09:08 +01:00
/**
* move similar tests in function doTest
* @param {Array} complimentsArray The array of compliments.
2024-01-01 15:38:08 +01:00
* @returns {boolean} result
2023-01-01 18:09:08 +01:00
*/
const doTest = async (complimentsArray) => {
let elem = await helpers.waitForElement(".compliments");
2024-01-01 15:38:08 +01:00
expect(elem).not.toBeNull();
2023-01-01 18:09:08 +01:00
elem = await helpers.waitForElement(".module-content");
2024-01-01 15:38:08 +01:00
expect(elem).not.toBeNull();
2023-01-01 18:09:08 +01:00
expect(complimentsArray).toContain(elem.textContent);
2024-01-01 15:38:08 +01:00
return true;
2023-01-01 18:09:08 +01:00
};
2021-09-25 23:37:37 +02:00
afterAll(async () => {
await helpers.stopApplication();
2021-09-25 23:37:37 +02:00
});
describe("Feature anytime in compliments module", () => {
2024-01-01 15:38:08 +01:00
describe("Set anytime and empty compliments for morning, evening and afternoon", () => {
2023-01-01 18:09:08 +01:00
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/compliments/compliments_anytime.js");
await helpers.getDocument();
2021-09-25 23:37:37 +02:00
});
2023-07-01 21:17:31 +02:00
it("shows anytime because if configure empty parts of day compliments and set anytime compliments", async () => {
2024-01-01 15:38:08 +01:00
await expect(doTest(["Anytime here"])).resolves.toBe(true);
2021-09-25 23:37:37 +02:00
});
});
describe("Only anytime present in configuration compliments", () => {
2023-01-01 18:09:08 +01:00
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/compliments/compliments_only_anytime.js");
await helpers.getDocument();
2021-09-25 23:37:37 +02:00
});
2023-07-01 21:17:31 +02:00
it("shows anytime compliments", async () => {
2024-01-01 15:38:08 +01:00
await expect(doTest(["Anytime here"])).resolves.toBe(true);
2021-09-25 23:37:37 +02:00
});
});
});
2023-01-01 18:09:08 +01:00
describe("remoteFile option", () => {
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/compliments/compliments_remote.js");
await helpers.getDocument();
});
2021-09-25 23:37:37 +02:00
2023-01-01 18:09:08 +01:00
it("should show compliments from a remote file", async () => {
2024-01-01 15:38:08 +01:00
await expect(doTest(["Remote compliment file works!"])).resolves.toBe(true);
2021-09-25 23:37:37 +02:00
});
});
2024-06-24 21:40:59 +01:00
describe("Feature specialDayUnique in compliments module", () => {
describe("specialDayUnique is false", () => {
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/compliments/compliments_specialDayUnique_false.js");
await helpers.getDocument();
});
it("compliments array can contain all values", async () => {
await expect(doTest(["Special day message", "Typical message 1", "Typical message 2", "Typical message 3"])).resolves.toBe(true);
});
});
describe("specialDayUnique is true", () => {
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/compliments/compliments_specialDayUnique_true.js");
await helpers.getDocument();
});
it("compliments array contains only special value", async () => {
await expect(doTest(["Special day message"])).resolves.toBe(true);
});
});
describe("cron type key", () => {
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/compliments/compliments_e2e_cron_entry.js");
await helpers.getDocument();
});
it("compliments array contains only special value", async () => {
await expect(doTest(["anytime cron"])).resolves.toBe(true);
});
});
2024-06-24 21:40:59 +01:00
});
2021-09-25 23:37:37 +02:00
});