From 8b1d1671f73d330c6d7656a8e1849407b16dffa6 Mon Sep 17 00:00:00 2001 From: rejas Date: Sat, 18 Jul 2020 21:10:36 +0200 Subject: [PATCH] Add test for changing the calendar symbol --- modules/default/calendar/calendar.js | 14 ++++++++------ tests/configs/modules/calendar/custom.js | 1 + tests/e2e/modules/calendar_spec.js | 12 ++++++++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index d0dd4022..06026363 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -13,8 +13,6 @@ Module.register("calendar", { maximumNumberOfDays: 365, displaySymbol: true, defaultSymbol: "calendar", // Fontawesome Symbol see https://fontawesome.com/cheatsheet?from=io - fullDaySymbol: "calendar", // Fontawesome Symbol - recurringSymbol: "calendar", // Fontawesome Symbol showLocation: false, displayRepeatingCountTitle: false, defaultRepeatingCountTitle: "", @@ -568,12 +566,12 @@ Module.register("calendar", { symbolsForEvent: function (event) { let symbols = this.getCalendarPropertyAsArray(event.url, "symbol", this.config.defaultSymbol); - if (event.recurringEvent === true) { - symbols = this.mergeUnique(this.getCalendarPropertyAsArray(event.url, "recurringSymbol", this.config.recurringSymbol), symbols); + if (event.recurringEvent === true && this.hasCalendarProperty(event.url, "recurringSymbol")) { + symbols = this.mergeUnique(this.getCalendarPropertyAsArray(event.url, "recurringSymbol", this.config.defaultSymbol), symbols); } - if (event.fullDayEvent === true) { - symbols = this.mergeUnique(this.getCalendarPropertyAsArray(event.url, "fullDaySymbol", this.config.recurringSymbol), symbols); + if (event.fullDayEvent === true && this.hasCalendarProperty(event.url, "fullDaySymbol")) { + symbols = this.mergeUnique(this.getCalendarPropertyAsArray(event.url, "fullDaySymbol", this.config.defaultSymbol), symbols); } return symbols; @@ -682,6 +680,10 @@ Module.register("calendar", { return p; }, + hasCalendarProperty: function (url, property) { + return !!this.getCalendarProperty(url, property, undefined); + }, + /** * Shortens a string if it's longer than maxLength and add a ellipsis to the end * diff --git a/tests/configs/modules/calendar/custom.js b/tests/configs/modules/calendar/custom.js index 2060bb1c..48a735b7 100644 --- a/tests/configs/modules/calendar/custom.js +++ b/tests/configs/modules/calendar/custom.js @@ -22,6 +22,7 @@ let config = { config: { calendars: [ { + symbol: "birthday-cake", maximumEntries: 3, maximumNumberOfDays: 10000, url: "http://localhost:8080/tests/configs/data/calendar_test.ics" diff --git a/tests/e2e/modules/calendar_spec.js b/tests/e2e/modules/calendar_spec.js index 19501158..b17212f4 100644 --- a/tests/e2e/modules/calendar_spec.js +++ b/tests/e2e/modules/calendar_spec.js @@ -37,6 +37,12 @@ describe("Calendar module", function () { const events = await app.client.$$(".calendar .event"); return expect(events.length).equals(10); }); + + it("Should show the default calendar symbol in each event", async () => { + await app.client.waitUntilTextExists(".calendar", "TestEvent", 10000); + const icons = await app.client.$$(".calendar .event .fa-calendar"); + return expect(icons.length).not.equals(0); + }); }); describe("Custom configuration", function () { @@ -50,6 +56,12 @@ describe("Calendar module", function () { const events = await app.client.$$(".calendar .event"); return expect(events.length).equals(3); }); + + it("Should show the custom calendar symbol in each event", async () => { + await app.client.waitUntilTextExists(".calendar", "TestEvent", 10000); + const icons = await app.client.$$(".calendar .event .fa-birthday-cake"); + return expect(icons.length).not.equals(0); + }); }); describe("Basic auth", function () {