Skip to content

Commit

Permalink
added parsing for VALARM (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnytest1 authored Feb 27, 2024
1 parent 97cc35b commit 6a5175e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions ical.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@ module.exports = {
if (typeof par[curr.uid].rrule !== 'undefined' && typeof par[curr.uid].recurrenceid !== 'undefined') {
delete par[curr.uid].recurrenceid;
}
} else if (component === 'VALARM' && (par.type === 'VEVENT' || par.type === 'VTODO')) {
par.alarms ??= [];
par.alarms.push(curr);
} else {
const id = uuid();
par[id] = curr;
Expand Down
11 changes: 9 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,11 @@ vows
},
'task completed'(task) {
assert.equal(task.summary, 'Event with an alarm');
assert.equal(task.alarms?.length, 1);
const alarm = task.alarms[0];
assert.equal(alarm.description, 'Reminder');
assert.equal(alarm.action, 'DISPLAY');
assert.equal(alarm.trigger.val, '-PT5M');
}
}
},
Expand All @@ -318,7 +323,9 @@ vows
return ical.parseFile('./test10.ics');
},
'grabbing custom properties': {
topic() {}
topic() {
//
}
}
},

Expand Down Expand Up @@ -883,7 +890,7 @@ vows
topic() {
ical.fromURL('http://255.255.255.255/', {}, this.callback);
},
'are passed back to the callback'(error, result) {
'are passed back to the callback': (error, result) => {
assert.instanceOf(error, Error);
if (!error) {
console.log('>E:', error, result);
Expand Down
4 changes: 2 additions & 2 deletions test/test2.ics
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ DTSTAMP:20021028T011706Z
SUMMARY:Coffee with Jason
UID:EC9439B1-FF65-11D6-9973-003065F99D04
DTEND;TZID=US/Pacific:20021028T150000
END:VEVENT
BEGIN:VALARM
TRIGGER;VALUE=DURATION:-P1D
ACTION:DISPLAY
DESCRIPTION:Event reminder
END:VALARM
END:VEVENT
BEGIN:VEVENT
SEQUENCE:1
DTSTAMP:20021128T012034Z
Expand All @@ -43,7 +43,6 @@ ATTENDEE;PARTSTAT=ACCEPTED:MAILTO:[email protected]
DUE:19980415T235959
STATUS:NEEDS-ACTION
SUMMARY:Submit Income Taxes
END:VTODO
BEGIN:VALARM
ACTION:AUDIO
TRIGGER:19980403T120000
Expand All @@ -52,6 +51,7 @@ ATTACH;FMTTYPE=audio/basic:http://host.com/pub/audio-
REPEAT:4
DURATION:PT1H
END:VALARM
END:VTODO
BEGIN:VJOURNAL
DTSTAMP:19970324T120000Z
UID:[email protected]
Expand Down

0 comments on commit 6a5175e

Please sign in to comment.