Skip to content

Commit 35de72b

Browse files
committed
add tests, rename to showNextEvent
1 parent 7ae44e6 commit 35de72b

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ planned for 2025-07-01
1313

1414
### Added
1515

16-
- [clock] Added option showSunNextEvent to show/hide next sun event.
16+
- [clock] Added option showNextEvent to show/hide next sun event.
1717

1818
### Changed
1919

modules/default/clock/clock.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Module.register("clock", {
2525
analogShowDate: "top", // OBSOLETE, can be replaced with analogPlacement and showTime, options: false, 'top', or 'bottom'
2626
secondsColor: "#888888", // DEPRECATED, use CSS instead. Class "clock-second-digital" for digital clock, "clock-second" for analog clock.
2727

28-
showSunTimes: false, // options: boolean, { showSunNextEvent: boolean }
28+
showSunTimes: false, // options: boolean, { showNextEvent: boolean }
2929
showMoonTimes: false, // options: false, 'times' (rise/set), 'percent' (lit percent), 'phase' (current phase), or 'both' (percent & phase)
3030
lat: 47.630539,
3131
lon: -122.344147
@@ -173,7 +173,7 @@ Module.register("clock", {
173173
const isVisible = now.isBetween(sunTimes.sunrise, sunTimes.sunset);
174174
let sunWrapperInnerHTML = "";
175175

176-
if (this.config.showSunTimes.showSunNextEvent !== false) {
176+
if (this.config.showSunTimes.showNextEvent !== false) {
177177
let nextEvent;
178178
if (now.isBefore(sunTimes.sunrise)) {
179179
nextEvent = sunTimes.sunrise;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
let config = {
2+
address: "0.0.0.0",
3+
ipWhitelist: [],
4+
timeFormat: 12,
5+
6+
modules: [
7+
{
8+
module: "clock",
9+
position: "middle_center",
10+
config: {
11+
showSunTimes: { showNextEvent: false }
12+
}
13+
}
14+
]
15+
};
16+
17+
/*************** DO NOT EDIT THE LINE BELOW ***************/
18+
if (typeof module !== "undefined") {
19+
module.exports = config;
20+
}

tests/e2e/modules/clock_spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ describe("Clock module", () => {
9292
it("should show the sun times", async () => {
9393
const elem = await helpers.waitForElement(".clock .digital .sun");
9494
expect(elem).not.toBeNull();
95+
96+
const elem2 = await helpers.waitForElement(".clock .digital .sun .fas.fa-sun");
97+
expect(elem2).not.toBeNull();
9598
});
9699

97100
it("should show the moon times", async () => {
@@ -100,6 +103,21 @@ describe("Clock module", () => {
100103
});
101104
});
102105

106+
describe("with showSunTimes.showNextEvent disabled", () => {
107+
beforeAll(async () => {
108+
await helpers.startApplication("tests/configs/modules/clock/clock_showSunNoEvent.js");
109+
await helpers.getDocument();
110+
});
111+
112+
it("should show the sun times", async () => {
113+
const elem = await helpers.waitForElement(".clock .digital .sun");
114+
expect(elem).not.toBeNull();
115+
116+
const elem2 = document.querySelector(".clock .digital .sun .fas.fa-sun");
117+
expect(elem2).toBeNull();
118+
});
119+
});
120+
103121
describe("with showWeek config enabled", () => {
104122
beforeAll(async () => {
105123
await helpers.startApplication("tests/configs/modules/clock/clock_showWeek.js");

0 commit comments

Comments
 (0)