Skip to content

Commit

Permalink
improve test, change icalendar recurring null-end-date behavior. fixes
Browse files Browse the repository at this point in the history
…#6190. further fixes #6139
  • Loading branch information
arshaw committed Mar 24, 2021
1 parent f0f675e commit efddcb5
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,12 +2,17 @@
v5.5.2
------

- fix: icalendar recurring events ignoring count rule (#6190)
- fix: icalendar recurring timed-events with wrong times (#6139)
- fix: removed accidental ical.js dependency in common's package.json (#6171)
- fix: for gcal events, restore extendedProperties (#5083)
- fix: for gcal events, make attachments available (#5024)
- fix: can't parse rrule strings with newlines after UNTIL statements (#6126)
- locale: fixed typos in Tamil (#6115)
- locale: added Bengali (#6096)
- breaking-change: for icalendar recurring event that don't specify dtend/duration,
the resulting Event object's end is now determined by forceEventDuration, defaultTimedEventDuration,
and defaultAllDayEventDuration, whereas previously it was *sometimes* null.


v5.5.1 (2021-01-16)
Expand Down
22 changes: 22 additions & 0 deletions packages/__tests__/src/icalendar/data/recurringWeeklyWithoutEnd.ts
@@ -0,0 +1,22 @@
export default `BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:events@fullcalendar.test
X-WR-TIMEZONE:Europe/Paris
BEGIN:VEVENT
DTSTART;TZID=Europe/Zurich:20190401T173000
RRULE:FREQ=WEEKLY;WKST=MO;BYDAY=MO
DTSTAMP:20201006T124223Z
ORGANIZER;CN=Testy McTestface:mailto:test@fullcalendar.test
UID:12345678
CREATED:20181210T150458Z
DESCRIPTION:
LAST-MODIFIED:20190508T170523Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Weekly Monday meeting
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR`
6 changes: 3 additions & 3 deletions packages/__tests__/src/icalendar/day-view.ts
Expand Up @@ -3,7 +3,7 @@ import timeGridPlugin from '@fullcalendar/timegrid'
import { EventSourceInput } from '@fullcalendar/core'
import iCalendarPlugin from '@fullcalendar/icalendar'
import oneHourMeeting from './data/oneHourMeeting'
import recurringWeeklyMeeting from './data/recurringWeeklyMeeting'
import recurringWeekly from './data/recurringWeekly'
import mungedOneHourMeeting from './data/mungedOneHourMeeting'
import meetingWithMungedStart from './data/meetingWithMungedStart'
import alldayEvent from './data/alldayEvent'
Expand Down Expand Up @@ -35,7 +35,7 @@ describe('addICalEventSource with day view', () => {
})

it('adds a repeating weekly meeting', (done) => {
loadICalendarWith(recurringWeeklyMeeting, () => {
loadICalendarWith(recurringWeekly, () => {
setTimeout(() => {
assertEventCount(1)
done()
Expand Down Expand Up @@ -98,7 +98,7 @@ describe('addICalEventSource with day view', () => {
setTimeout(() => {
assertEventCount(1)
const event = currentCalendar.getEvents()[0]
expect(event.end).toBeNull()
expect(event.end).toBe(null)
done()
}, 100)
},
Expand Down
26 changes: 21 additions & 5 deletions packages/__tests__/src/icalendar/month-view.ts
Expand Up @@ -8,7 +8,8 @@ import multidayEvent from './data/multidayEvent'
import multipleMultidayEvents from './data/multipleMultidayEvents'
import multipleEventsOneMunged from './data/multipleEventsOneMunged'
import oneHourMeeting from './data/oneHourMeeting'
import recurringWeeklyMeeting from './data/recurringWeeklyMeeting'
import recurringWeekly from './data/recurringWeekly'
import recurringWeeklyWithoutEnd from './data/recurringWeeklyWithoutEnd'
import recurringWeeklyWithCount from './data/recurringWeeklyWithCount'
import mungedOneHourMeeting from './data/mungedOneHourMeeting'

Expand All @@ -27,8 +28,10 @@ describe('addICalEventSource with month view', () => {
it('adds an all day event', (done) => {
loadICalendarWith(alldayEvent, () => {
setTimeout(() => {
let events = currentCalendar.getEvents()
expect(events[0].end).toBe(null)
events.forEach((event) => expect(event.allDay).toBeTruthy())
assertEventCount(1)
currentCalendar.getEvents().forEach((event) => expect(event.allDay).toBeTruthy())
done()
}, 100)
})
Expand Down Expand Up @@ -68,10 +71,23 @@ describe('addICalEventSource with month view', () => {
})

it('adds a repeating weekly meeting', (done) => {
loadICalendarWith(recurringWeeklyMeeting, () => {
loadICalendarWith(recurringWeekly, () => {
setTimeout(() => {
let events = currentCalendar.getEvents()
expect(events[0].start).toEqualDate('2019-04-01T17:30:00')
expect(events[0].end).toEqualDate('2019-04-01T18:30:00')
assertEventCount(6)
done()
}, 100)
})
})

it('adds a repeating weekly meeting, with null end', (done) => {
loadICalendarWith(recurringWeeklyWithoutEnd, () => {
setTimeout(() => {
let events = currentCalendar.getEvents()
expect(events[0].start).toEqualDate('2019-04-01T17:30:00')
expect(events[0].end).toBe(null)
assertEventCount(6)
done()
}, 100)
Expand Down Expand Up @@ -108,14 +124,14 @@ describe('addICalEventSource with month view', () => {
})
})

it('defaultAllDayEventDuration does not override ical default all day length of one day', (done) => {
it('defaultAllDayEventDuration overrides ical default all day length of one day', (done) => {
loadICalendarWith(
alldayEvent,
() => {
setTimeout(() => {
assertEventCount(1)
const event = currentCalendar.getEvents()[0]
expect(event.end.getDate()).toEqual(event.start.getDate() + 1)
expect(event.end.getDate()).toEqual(event.start.getDate() + 2)
done()
}, 100)
},
Expand Down
8 changes: 5 additions & 3 deletions packages/icalendar/src/main.ts
Expand Up @@ -172,9 +172,10 @@ function expandRecurringEvent(iCalEvent: ICAL.Event, range: DateRange): EventInp
while ((startDateTime = expansion.next())) { // will start expanding ALL occurences
let startDate = startDateTime.toJSDate()
let endDate: DateMarker | null = null
let endDateTime: ICAL.Time | null = null

if (hasDuration) {
let endDateTime = startDateTime.clone()
endDateTime = startDateTime.clone()
endDateTime.addDuration(iCalEvent.duration)
endDate = endDateTime.toJSDate()
}
Expand All @@ -185,7 +186,7 @@ function expandRecurringEvent(iCalEvent: ICAL.Event, range: DateRange): EventInp
eventInputs.push({
title: iCalEvent.summary,
start: startDateTime.toString(),
end: endDate,
end: endDateTime ? endDateTime.toString() : null,
})
}
}
Expand All @@ -194,7 +195,8 @@ function expandRecurringEvent(iCalEvent: ICAL.Event, range: DateRange): EventInp
}

function specifiesEnd(iCalEvent: ICAL.Event) {
return Boolean(iCalEvent.component.getFirstProperty('dtend'))
return Boolean(iCalEvent.component.getFirstProperty('dtend')) ||
Boolean(iCalEvent.component.getFirstProperty('duration'))
}

export default createPlugin({
Expand Down

0 comments on commit efddcb5

Please sign in to comment.