Commit 1a85edc2 authored by Sebastian's avatar Sebastian
Browse files

calendar description

X-WR-CALDESC Support [close #37]
parent 2e5d3166
......@@ -8,7 +8,7 @@
*/
var ICalCalendar = function(_data) {
var data = {},
attributes = ['domain', 'prodId', 'name', 'timezone', 'ttl', 'url', 'events'],
attributes = ['domain', 'prodId', 'name', 'description', 'timezone', 'ttl', 'url', 'events'],
generate,
i;
......@@ -34,6 +34,11 @@ var ICalCalendar = function(_data) {
g += 'X-WR-CALNAME:' + data.name + '\r\n';
}
// Description
if(data.description) {
g += 'X-WR-CALDESC:' + data.description + '\r\n';
}
// Timezone
if(data.timezone) {
g += 'TIMEZONE-ID:' + data.timezone + '\r\n';
......@@ -197,6 +202,23 @@ var ICalCalendar = function(_data) {
};
/**
* Set/Get your feed's description…
*
* @param [description] Description
* @since 0.2.7
* @returns {ICalCalendar}
*/
this.description = function(description) {
if(!description) {
return data.description;
}
data.description = description.toString();
return this;
};
/**
* Set your feed's timezone.
* Used to set `X-WR-TIMEZONE`.
......
......@@ -136,6 +136,28 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
});
});
describe('description()', function() {
it('setter should return this', function() {
var cal = ical();
assert.deepEqual(cal, cal.description('Testbeschreibung'));
});
it('getter should return value', function() {
var cal = ical().description('Testbeschreibung');
assert.equal(cal.description(), 'Testbeschreibung');
});
it('should change something', function() {
var cal = ical().description('Testbeschreibung');
cal.createEvent({
start: new Date(),
end: new Date(new Date().getTime() + 3600000),
summary: 'Example Event'
});
assert.ok(cal.toString().indexOf('Testbeschreibung') > -1);
});
});
describe('timezone()', function() {
it('setter should return this', function() {
var cal = ical();
......
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