Commit eac9245a authored by Sebastian's avatar Sebastian
Browse files

Documentation, tests and fallback for PR #39

parent 45916060
......@@ -180,6 +180,10 @@ Use this method to set your feed's timezone. Is used to fill `TIMEZONE-ID` and `
var cal = ical().timezone('Europe/Berlin');
```
#### method([_String_ method])
Calendar method. May be any of the following: `publish`, `request`, `reply`, `add`, `cancel`, `refresh`, `counter`, `declinecounter`.
#### ttl([_Number_ ttl])
......@@ -443,11 +447,6 @@ cal.attendees(); // --> [ICalAlarm, ICalAlarm]
Appointment URL
#### method([_String_ method])
Appointment method. May be any of the following: `publish`, `request`, `reply`, `add`, `cancel`, `refresh`, `counter`, `declinecounter`.
#### status([_String_ status])
Appointment status. May be any of the following: `confirmed`, `tenative`, `cancelled`.
......
......@@ -185,8 +185,8 @@ var ICalCalendar = function(_data) {
* Set/Get your feed's method
*
* @param {String} method
* @since 0.2.0
* @returns {ICalEvent|String}
* @since 0.2.8
* @returns {ICalCalendar|String}
*/
this.method = function(method) {
if(method === undefined) {
......
......@@ -7,7 +7,7 @@
* @constructor ICalEvent Event
*/
var ICalEvent = function(_data, calendar) {
var attributes = ['id', 'uid', 'sequence', 'start', 'end', 'timezone', 'stamp', 'timestamp', 'allDay', 'floating', 'repeating', 'summary', 'location', 'description', 'organizer', 'attendees', 'alarms', 'status', 'url'],
var attributes = ['id', 'uid', 'sequence', 'start', 'end', 'timezone', 'stamp', 'timestamp', 'allDay', 'floating', 'repeating', 'summary', 'location', 'description', 'organizer', 'attendees', 'alarms', 'method', 'status', 'url'],
vars,
i,
data;
......@@ -539,6 +539,28 @@ var ICalEvent = function(_data, calendar) {
};
/**
* Set/Get your feed's method
*
* @param {String} method
* @since 0.2.0
* @deprecated since 0.2.8
* @returns {ICalEvent|String}
*/
this.method = function(method) {
if(method === undefined) {
return calendar.method();
}
if(!method) {
calendar.method(null);
return this;
}
calendar.method(method);
return this;
};
/**
* Set/Get the event's status
*
......
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN
METHOD:ADD
BEGIN:VEVENT
UID:123@sebbo.net
SEQUENCE:0
......@@ -12,7 +13,6 @@ X-MICROSOFT-MSNCALENDAR-ALLDAYEVENT:TRUE
SUMMARY:Sample Event
ORGANIZER;CN="Sebastian Pekarek":mailto:mail@sebbo.net
URL;VALUE=URI:http://sebbo.net/
METHOD:ADD
STATUS:CONFIRMED
END:VEVENT
END:VCALENDAR
\ No newline at end of file
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN
METHOD:PUBLISH
BEGIN:VEVENT
UID:123@sebbo.net
SEQUENCE:0
......@@ -26,7 +27,6 @@ TRIGGER:-PT1H
DESCRIPTION:I'm a reminder :)
END:VALARM
URL;VALUE=URI:http://sebbo.net/
METHOD:ADD
STATUS:CONFIRMED
END:VEVENT
END:VCALENDAR
\ No newline at end of file
......@@ -346,7 +346,7 @@ describe('ical-generator 0.1.x', function() {
summary: 'hello',
method: 'hello world'
});
}, /event\.method must be one of the following/);
}, /method must be one of the following/);
});
it('should throw an error if status is not allowed', function() {
......
......@@ -119,6 +119,40 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
});
});
describe('method()', function() {
it('setter should return this', function() {
var c = ical();
assert.deepEqual(c, c.method(null));
assert.deepEqual(c, c.method('publish'));
});
it('getter should return value', function() {
var c = ical();
assert.equal(c.method(), null);
c.method(null);
assert.equal(c.method(), null);
c.method('publish');
assert.equal(c.method(), 'PUBLISH');
c.method(null);
assert.equal(c.method(), null);
});
it('should throw error when method not allowed', function() {
var c = ical();
assert.throws(function() {
c.method('KICK ASS');
}, /`method`/);
});
it('should change something', function() {
var c = ical({method: 'publish'}),
str = c.toString();
c.method('add');
assert.ok(str !== c.toString());
});
});
describe('name()', function() {
it('setter should return this', function() {
var cal = ical();
......@@ -1466,7 +1500,7 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
});
it('case #6 (attendee with simple delegation and alarm)', function() {
var cal = ical({domain: 'sebbo.net', prodId: '//sebbo.net//ical-generator.tests//EN'}),
var cal = ical({domain: 'sebbo.net', prodId: '//sebbo.net//ical-generator.tests//EN', method: 'publish'}),
string, json;
cal.createEvent({
id: '123',
......@@ -1500,7 +1534,6 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
description: 'I\'m a reminder :)'
}
],
method: 'add',
status: 'confirmed',
url: 'http://sebbo.net/'
});
......
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