Commit 1b679d0a authored by Sebastian Pekarek's avatar Sebastian Pekarek
Browse files

Add unit tests for #9

parent 9e67a68c
......@@ -188,9 +188,7 @@ var a = {
g += 'DTEND:' + _formatDate(e.end) + '\n';
}
if(e.summary) {
g += 'SUMMARY:' + _escape(e.summary) + '\n';
}
g += 'SUMMARY:' + _escape(e.summary) + '\n';
if(e.location) {
g += 'LOCATION:' + _escape(e.location) + '\n';
}
......@@ -222,7 +220,7 @@ var a = {
if(!cal.generated) {
cal.methods.generate();
}
require('fs').writeFile(path, cal.generated, cb || function(){});
require('fs').writeFile(path, cal.generated, cb);
return cal.methods;
},
saveSync: function(path) {
......
......@@ -9,5 +9,7 @@ DTEND;VALUE=DATE:20131006Z
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
......@@ -236,6 +236,34 @@ describe('ical-generator', function() {
});
}, /event\.organizer\.email is empty/);
});
it('should throw an error if method is not allowed', function() {
var generator = require(__dirname + '/../lib/ical-generator.js'),
cal = generator();
assert.throws(function() {
cal.addEvent({
start: new Date(),
end: new Date(),
summary: 'hello',
method:'hello world'
});
}, /event\.method must be one of the following/);
});
it('should throw an error if status is not allowed', function() {
var generator = require(__dirname + '/../lib/ical-generator.js'),
cal = generator();
assert.throws(function() {
cal.addEvent({
start: new Date(),
end: new Date(),
summary: 'hello',
status:'hello world'
});
}, /event\.status must be one of the following/);
});
});
......@@ -315,6 +343,8 @@ describe('ical-generator', function() {
name: 'Sebastian Pekarek',
email: 'mail@sebbo.net'
},
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