Skip to content

Commit

Permalink
Unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jkriegshauser committed Oct 26, 2023
1 parent b14db2a commit 5952093
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.eslintignore
.prettierignore
/config
/coverage
package-lock.json
**.ics
36 changes: 36 additions & 0 deletions tests/configs/modules/calendar/exdate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* MagicMirror² Test calendar exdate
*
* By jkriegshauser
* MIT Licensed.
*
* NOTE: calendar_test_exdate.ics has exdate entries for the next 20 years, but without some
* way to set a debug date for tests, this test may become flaky on specific days (i.e. could
* not test easily on leap-years, the BYDAY specified in exdate, etc.) or when the 20 years
* elapses if this project is still in active development ;)
* See issue #3250
*/
let config = {
timeFormat: 12,

modules: [
{
module: "calendar",
position: "bottom_bar",
config: {
maximumEntries: 100,
calendars: [
{
maximumEntries: 100,
maximumNumberOfDays: 364,
url: "http://localhost:8080/tests/mocks/calendar_test_exdate.ics"
}
]
}
}
]
};

/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {
module.exports = config;
}
11 changes: 11 additions & 0 deletions tests/e2e/modules/calendar_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ describe("Calendar module", () => {
});
});

describe("exdate check", () => {
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/calendar/exdate.js");
await helpers.getDocument();
});

it("should show the recurring event 51 times (excluded once) in a 364-day (inclusive) period", async () => {
await testElementLength(".calendar .event", 51);
});
});

describe("Events from multiple calendars", () => {
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/calendar/show-duplicates-in-calendar.js");
Expand Down
34 changes: 34 additions & 0 deletions tests/mocks/calendar_test_exdate.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
BEGIN:VEVENT
DTSTART;TZID=America/Los_Angeles:20231025T181000
DTEND;TZID=America/Los_Angeles:20231025T195000
RRULE:FREQ=WEEKLY;BYDAY=WE
EXDATE;TZID=America/Los_Angeles:20231101T181000
EXDATE;TZID=America/Los_Angeles:20241030T181000
EXDATE;TZID=America/Los_Angeles:20251029T181000
EXDATE;TZID=America/Los_Angeles:20261028T181000
EXDATE;TZID=America/Los_Angeles:20271027T181000
EXDATE;TZID=America/Los_Angeles:20281025T181000
EXDATE;TZID=America/Los_Angeles:20291024T181000
EXDATE;TZID=America/Los_Angeles:20301023T181000
EXDATE;TZID=America/Los_Angeles:20311022T181000
EXDATE;TZID=America/Los_Angeles:20321020T181000
EXDATE;TZID=America/Los_Angeles:20331019T181000
EXDATE;TZID=America/Los_Angeles:20341018T181000
EXDATE;TZID=America/Los_Angeles:20351017T181000
EXDATE;TZID=America/Los_Angeles:20361015T181000
EXDATE;TZID=America/Los_Angeles:20371014T181000
EXDATE;TZID=America/Los_Angeles:20381013T181000
EXDATE;TZID=America/Los_Angeles:20391012T181000
EXDATE;TZID=America/Los_Angeles:20401010T181000
EXDATE;TZID=America/Los_Angeles:20411009T181000
EXDATE;TZID=America/Los_Angeles:20421008T181000
EXDATE;TZID=America/Los_Angeles:20431007T181000
DTSTAMP:20231025T233434Z
UID:[email protected]
CREATED:20230306T193128Z
LAST-MODIFIED:20231024T222515Z
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:My Event
TRANSP:OPAQUE
END:VEVENT

0 comments on commit 5952093

Please sign in to comment.