-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't filter out ongoing full day events in Calendar module (#3095…
…) (#3096) Fixes #3095. Param `hideOngoing` is by default set to `false`, but the event filtering handles `full day` & `non-full day` events inconsistently. For `non-full day` _ongoing_ and _upcoming_ events are returned, while for `full day` only _upcoming_ events where returned.
- Loading branch information
1 parent
e09d60d
commit 83315f1
Showing
3 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
tests/unit/modules/default/calendar/calendar_fetcher_utils_spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
global.moment = require("moment-timezone"); | ||
|
||
const CalendarFetcherUtils = require("../../../../../modules/default/calendar/calendarfetcherutils"); | ||
|
||
describe("Calendar fetcher utils test", () => { | ||
const defaultConfig = { | ||
excludedEvents: [], | ||
includePastEvents: false, | ||
maximumEntries: 10, | ||
maximumNumberOfDays: 365 | ||
}; | ||
|
||
describe("filterEvents", () => { | ||
it("should return only ongoing and upcoming non full day events", () => { | ||
const minusOneHour = moment().subtract(1, "hours").toDate(); | ||
const minusTwoHours = moment().subtract(2, "hours").toDate(); | ||
const plusOneHour = moment().add(1, "hours").toDate(); | ||
const plusTwoHours = moment().add(2, "hours").toDate(); | ||
|
||
const filteredEvents = CalendarFetcherUtils.filterEvents( | ||
{ | ||
pastEvent: { type: "VEVENT", start: minusTwoHours, end: minusOneHour, summary: "pastEvent" }, | ||
ongoingEvent: { type: "VEVENT", start: minusOneHour, end: plusOneHour, summary: "ongoingEvent" }, | ||
upcomingEvent: { type: "VEVENT", start: plusOneHour, end: plusTwoHours, summary: "upcomingEvent" } | ||
}, | ||
defaultConfig | ||
); | ||
|
||
expect(filteredEvents.length).toEqual(2); | ||
expect(filteredEvents[0].title).toBe("ongoingEvent"); | ||
expect(filteredEvents[1].title).toBe("upcomingEvent"); | ||
}); | ||
|
||
it("should return only ongoing and upcoming full day events", () => { | ||
const yesterday = moment().subtract(1, "days").startOf("day").toDate(); | ||
const today = moment().startOf("day").toDate(); | ||
const tomorrow = moment().add(1, "days").startOf("day").toDate(); | ||
|
||
const filteredEvents = CalendarFetcherUtils.filterEvents( | ||
{ | ||
pastEvent: { type: "VEVENT", start: yesterday, end: yesterday, summary: "pastEvent" }, | ||
ongoingEvent: { type: "VEVENT", start: today, end: today, summary: "ongoingEvent" }, | ||
upcomingEvent: { type: "VEVENT", start: tomorrow, end: tomorrow, summary: "upcomingEvent" } | ||
}, | ||
defaultConfig | ||
); | ||
|
||
expect(filteredEvents.length).toEqual(2); | ||
expect(filteredEvents[0].title).toBe("ongoingEvent"); | ||
expect(filteredEvents[1].title).toBe("upcomingEvent"); | ||
}); | ||
}); | ||
}); |