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 ` ...@@ -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'); 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]) #### ttl([_Number_ ttl])
...@@ -443,11 +447,6 @@ cal.attendees(); // --> [ICalAlarm, ICalAlarm] ...@@ -443,11 +447,6 @@ cal.attendees(); // --> [ICalAlarm, ICalAlarm]
Appointment URL Appointment URL
#### method([_String_ method])
Appointment method. May be any of the following: `publish`, `request`, `reply`, `add`, `cancel`, `refresh`, `counter`, `declinecounter`.
#### status([_String_ status]) #### status([_String_ status])
Appointment status. May be any of the following: `confirmed`, `tenative`, `cancelled`. Appointment status. May be any of the following: `confirmed`, `tenative`, `cancelled`.
......
...@@ -185,8 +185,8 @@ var ICalCalendar = function(_data) { ...@@ -185,8 +185,8 @@ var ICalCalendar = function(_data) {
* Set/Get your feed's method * Set/Get your feed's method
* *
* @param {String} method * @param {String} method
* @since 0.2.0 * @since 0.2.8
* @returns {ICalEvent|String} * @returns {ICalCalendar|String}
*/ */
this.method = function(method) { this.method = function(method) {
if(method === undefined) { if(method === undefined) {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* @constructor ICalEvent Event * @constructor ICalEvent Event
*/ */
var ICalEvent = function(_data, calendar) { 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, vars,
i, i,
data; data;
...@@ -539,6 +539,28 @@ var ICalEvent = function(_data, calendar) { ...@@ -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 * Set/Get the event's status
* *
......
BEGIN:VCALENDAR BEGIN:VCALENDAR
VERSION:2.0 VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN PRODID:-//sebbo.net//ical-generator.tests//EN
METHOD:ADD
BEGIN:VEVENT BEGIN:VEVENT
UID:123@sebbo.net UID:123@sebbo.net
SEQUENCE:0 SEQUENCE:0
...@@ -12,7 +13,6 @@ X-MICROSOFT-MSNCALENDAR-ALLDAYEVENT:TRUE ...@@ -12,7 +13,6 @@ X-MICROSOFT-MSNCALENDAR-ALLDAYEVENT:TRUE
SUMMARY:Sample Event SUMMARY:Sample Event
ORGANIZER;CN="Sebastian Pekarek":mailto:mail@sebbo.net ORGANIZER;CN="Sebastian Pekarek":mailto:mail@sebbo.net
URL;VALUE=URI:http://sebbo.net/ URL;VALUE=URI:http://sebbo.net/
METHOD:ADD
STATUS:CONFIRMED STATUS:CONFIRMED
END:VEVENT END:VEVENT
END:VCALENDAR END:VCALENDAR
\ No newline at end of file
BEGIN:VCALENDAR BEGIN:VCALENDAR
VERSION:2.0 VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN PRODID:-//sebbo.net//ical-generator.tests//EN
METHOD:PUBLISH
BEGIN:VEVENT BEGIN:VEVENT
UID:123@sebbo.net UID:123@sebbo.net
SEQUENCE:0 SEQUENCE:0
...@@ -26,7 +27,6 @@ TRIGGER:-PT1H ...@@ -26,7 +27,6 @@ TRIGGER:-PT1H
DESCRIPTION:I'm a reminder :) DESCRIPTION:I'm a reminder :)
END:VALARM END:VALARM
URL;VALUE=URI:http://sebbo.net/ URL;VALUE=URI:http://sebbo.net/
METHOD:ADD
STATUS:CONFIRMED STATUS:CONFIRMED
END:VEVENT END:VEVENT
END:VCALENDAR END:VCALENDAR
\ No newline at end of file
...@@ -346,7 +346,7 @@ describe('ical-generator 0.1.x', function() { ...@@ -346,7 +346,7 @@ describe('ical-generator 0.1.x', function() {
summary: 'hello', summary: 'hello',
method: 'hello world' 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() { it('should throw an error if status is not allowed', function() {
......
...@@ -119,6 +119,40 @@ describe('ical-generator 0.2.x / ICalCalendar', 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() { describe('name()', function() {
it('setter should return this', function() { it('setter should return this', function() {
var cal = ical(); var cal = ical();
...@@ -1466,7 +1500,7 @@ describe('ical-generator 0.2.x / ICalCalendar', function() { ...@@ -1466,7 +1500,7 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
}); });
it('case #6 (attendee with simple delegation and alarm)', 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; string, json;
cal.createEvent({ cal.createEvent({
id: '123', id: '123',
...@@ -1500,7 +1534,6 @@ describe('ical-generator 0.2.x / ICalCalendar', function() { ...@@ -1500,7 +1534,6 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
description: 'I\'m a reminder :)' description: 'I\'m a reminder :)'
} }
], ],
method: 'add',
status: 'confirmed', status: 'confirmed',
url: 'http://sebbo.net/' 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