Skip to content

Commit

Permalink
add tests, fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sujal committed Feb 23, 2024
1 parent 856f404 commit 6e75f29
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ical.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ const dateParameter = function (name) {
const vTimezone =
Object.values(stackItemWithTimeZone).find(({type}) => type === 'VTIMEZONE');

// if the VTIMEZONE contains multiple TZIDs, use the last one in order
const normalizedTzId = vTimezone ?
Array.isArray(vTimezone.tzid) ? vTimezone.tzid[vTimezone.tzid.length - 1] : vTimezone.tzid :
// If the VTIMEZONE contains multiple TZIDs, use the last one in order
const normalizedTzId = vTimezone ?
(Array.isArray(vTimezone.tzid) ? vTimezone.tzid[vTimezone.tzid.length - 1] : vTimezone.tzid) :
null;

newDate = normalizedTzId && moment.tz.zone(normalizedTzId) ?
Expand Down
16 changes: 16 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,22 @@ vows
assert.equal(topic.start.tz, 'Europe/Berlin');
}
}
},
'with test_with_multiple_tzids_in_vtimezone.ics': {
topic() {
return ical.parseFile('./test/test_with_multiple_tzids_in_vtimezone.ics');
},
'using a vtimezone with multiple timezone': {
topic(events) {
return _.select(_.values(events), x => {
return x.uid === '[email protected]';
})[0];
},
'has a start'(topic) {
assert.equal(topic.start.toJSON(), '2024-06-27T07:00:00.000Z');
assert.equal(topic.end.toJSON(), '2024-06-28T06:00:00.000Z');
}
}
}
})
.export(module);
46 changes: 46 additions & 0 deletions test/test_with_multiple_tzids_in_vtimezone.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Hathaway Elementary School - ECPv6.3.3//NONSGML v1.0//EN
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:Hathaway Elementary School
X-ORIGINAL-URL:https://www.washougal.k12.wa.us/hathaway
X-WR-CALDESC:Events for Hathaway Elementary School
REFRESH-INTERVAL;VALUE=DURATION:PT1H
X-Robots-Tag:noindex
X-PUBLISHED-TTL:PT1H
BEGIN:VTIMEZONE
TZID:Africa/Abidjan
BEGIN:STANDARD
TZOFFSETFROM:+0000
TZOFFSETTO:+0000
TZNAME:GMT
DTSTART:20240101T000000
END:STANDARD
TZID:America/Los_Angeles
BEGIN:DAYLIGHT
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
TZNAME:PDT
DTSTART:20240310T100000
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
TZNAME:PST
DTSTART:20241103T090000
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTART:20240627T000000
DTEND:20240627T230000
DTSTAMP:20240222T162327
CREATED:20231129T014844Z
LAST-MODIFIED:20240222T184259Z
UID:[email protected]
SUMMARY:Possible Snow Makeup Day
DESCRIPTION:This day is a snow makeup day\, and will be added back to the calendar if needed. If we do not have any snow closure\, this is a non-attendance day for students.  \nFor a list of all calendar related closures and important dates\, please visit our calendar page at https://www.washougal.k12.wa.us/calendar/
URL:https://www.washougal.k12.wa.us/hathaway/event/possible-snow-makeup-day/
CATEGORIES:School Events
END:VEVENT
END:VCALENDAR

0 comments on commit 6e75f29

Please sign in to comment.