Fix undefined error for showSunTime / showMoonTime in clock module (#3146)

Fixes #3143 and adds tests for showSunTime / showMoonTime
This commit is contained in:
Veeck
2023-07-02 22:10:58 +02:00
committed by GitHub
parent 62eb23ba6a
commit f802c85a38
7 changed files with 93 additions and 50 deletions

View File

@@ -0,0 +1,24 @@
/* MagicMirror² Test config for default clock module
*
* By Johan Hammar
* MIT Licensed.
*/
let config = {
timeFormat: 12,
modules: [
{
module: "clock",
position: "middle_center",
config: {
showSunTimes: true,
showMoonTimes: true
}
}
]
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {
module.exports = config;
}

View File

@@ -71,11 +71,28 @@ describe("Clock module", () => {
});
it("should not show the time when digital clock is shown", async () => {
const elem = await document.querySelector(".clock .digital .time");
const elem = document.querySelector(".clock .digital .time");
expect(elem).toBe(null);
});
});
describe("with showSun/MoonTime enabled", () => {
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/clock/clock_showSunMoon.js");
await helpers.getDocument();
});
it("should show the sun times", async () => {
const elem = await helpers.waitForElement(".clock .digital .sun");
expect(elem).not.toBe(null);
});
it("should show the moon times", async () => {
const elem = await helpers.waitForElement(".clock .digital .moon");
expect(elem).not.toBe(null);
});
});
describe("with showWeek config enabled", () => {
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/clock/clock_showWeek.js");

View File

@@ -25,8 +25,8 @@ describe("Newsfeed module", () => {
it("should NOT show the newsfeed description", async () => {
await helpers.waitForElement(".newsfeed");
const element = document.querySelector(".newsfeed .newsfeed-desc");
expect(element).toBe(null);
const elem = document.querySelector(".newsfeed .newsfeed-desc");
expect(elem).toBe(null);
});
});