Commit d26a3ca6 authored by Sebastian Pekarek's avatar Sebastian Pekarek
Browse files

ICalAlarm.generate() tests

parent 40466215
......@@ -10,6 +10,16 @@ SUMMARY:Sample Event
ORGANIZER;CN="Sebastian Pekarek":mailto:mail@sebbo.net
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;DELEGATED-FROM="matt@example.com";CN="John":MAILTO:john@example.com
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=DELEGATED;DELEGATED-TO="john@example.com";CN="Matt":MAILTO:matt@example.com
BEGIN:VALARM
ACTION:DISPLAY
TRIGGER:-PT10M
REPEAT:2
DURATION:PT1M
END:VALARM
BEGIN:VALARM
ACTION:DISPLAY
TRIGGER:-PT1H
END:VALARM
URL;VALUE=URI:http://sebbo.net/
METHOD:ADD
STATUS:CONFIRMED
......
......@@ -1052,7 +1052,7 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
assert.equal(cal.toString(), fs.readFileSync(__dirname + '/results/generate_05.ics', 'utf8'));
});
it('case #6 (attendee with simple delegation)', function() {
it('case #6 (attendee with simple delegation and alarm)', function() {
var cal = ical({domain: 'sebbo.net', prodId: '//sebbo.net//ical-generator.tests//EN'});
cal.createEvent({
id: '123',
......@@ -1073,6 +1073,18 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
}
}
],
alarms: [
{
type: 'display',
trigger: 60 * 10,
repeat: 2,
interval: 60
},
{
type: 'display',
trigger: 60 * 60
}
],
method: 'add',
status: 'confirmed',
url: 'http://sebbo.net/'
......@@ -1515,5 +1527,55 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
assert.ok(cal.toString().indexOf('DURATION:PT1M30S') > -1);
});
});
describe('generate()', function() {
it('shoult throw an error without type', function() {
var a = ical().createEvent({
start: new Date(),
end: new Date(new Date().getTime() + 3600000),
summary: 'Example Event'
}).createAlarm({trigger: 300});
assert.throws(function() {
a.generate();
}, /`type`/);
});
it('shoult throw an error without trigger', function() {
var a = ical().createEvent({
start: new Date(),
end: new Date(new Date().getTime() + 3600000),
summary: 'Example Event'
}).createAlarm({type: 'display'});
assert.throws(function() {
a.generate();
}, /`trigger`/);
});
it('shoult throw an error if repeat is set but interval isn\'t', function() {
var a = ical().createEvent({
start: new Date(),
end: new Date(new Date().getTime() + 3600000),
summary: 'Example Event'
}).createAlarm({type: 'display', trigger: 300, repeat: 4});
assert.throws(function() {
a.generate();
}, /for `interval`/);
});
it('shoult throw an error if interval is set but repeat isn\'t', function() {
var a = ical().createEvent({
start: new Date(),
end: new Date(new Date().getTime() + 3600000),
summary: 'Example Event'
}).createAlarm({type: 'display', trigger: 300, interval: 60});
assert.throws(function() {
a.generate();
}, /for `repeat`/);
});
});
});
});
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment