diff options
author | James Lal <james@lightsofapollo.com> | 2012-07-24 09:20:16 -0700 |
---|---|---|
committer | James Lal <james@lightsofapollo.com> | 2012-07-24 09:20:16 -0700 |
commit | 55aa47aab5bba0126d33ff44fa0dbf7472a2d91a (patch) | |
tree | 20137cb87a9a1dbd754692c8c38e0f60ba0ac63f | |
parent | cbb1142c4dcefeffe47d85a14ea65fc23c9739a2 (diff) | |
download | jsCalDAV-55aa47aab5bba0126d33ff44fa0dbf7472a2d91a.tar.gz |
add some tests
-rw-r--r-- | samples/ical/event.ics | 51 | ||||
-rw-r--r-- | samples/xml/calendar_query_single.xml | 63 | ||||
-rw-r--r-- | test/caldav/ical_test.js | 21 | ||||
-rw-r--r-- | test/caldav/sax/dav_response_test.js | 27 |
4 files changed, 160 insertions, 2 deletions
diff --git a/samples/ical/event.ics b/samples/ical/event.ics new file mode 100644 index 0000000..c7e9c48 --- /dev/null +++ b/samples/ical/event.ics @@ -0,0 +1,51 @@ +BEGIN:VCALENDAR +PRODID:-//Google Inc//Google Calendar 70.9054//EN +VERSION:2.0 +CALSCALE:GREGORIAN +X-WR-CALNAME:calmozilla1@gmail.com +X-WR-TIMEZONE:America/Los_Angeles +BEGIN:VTIMEZONE +TZID:America/Los_Angeles +X-LIC-LOCATION:America/Los_Angeles +BEGIN:DAYLIGHT +TZOFFSETFROM:-0800 +TZOFFSETTO:-0700 +TZNAME:PDT +DTSTART:19700308T020000 +RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU +END:DAYLIGHT +BEGIN:STANDARD +TZOFFSETFROM:-0700 +TZOFFSETTO:-0800 +TZNAME:PST +DTSTART:19701101T020000 +RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU +END:STANDARD +END:VTIMEZONE +BEGIN:VEVENT +DTSTART;TZID=America/Los_Angeles:20120629T130000 +DTEND;TZID=America/Los_Angeles:20120629T140000 +DTSTAMP:20120629T112428Z +UID:0kusnhnnacaok1r02v16simh8c@google.com +CREATED:20120629T111935Z +DESCRIPTION: +LAST-MODIFIED:20120629T112428Z +LOCATION:Barcelona +SEQUENCE:0 +STATUS:CONFIRMED +SUMMARY:Demo B2G Calendar +TRANSP:OPAQUE +BEGIN:VALARM +ACTION:EMAIL +DESCRIPTION:This is an event reminder +SUMMARY:Alarm notification +ATTENDEE:mailto:calmozilla1@gmail.com +TRIGGER:-P0DT0H30M0S +END:VALARM +BEGIN:VALARM +ACTION:DISPLAY +DESCRIPTION:This is an event reminder +TRIGGER:-P0DT0H30M0S +END:VALARM +END:VEVENT +END:VCALENDAR diff --git a/samples/xml/calendar_query_single.xml b/samples/xml/calendar_query_single.xml new file mode 100644 index 0000000..9fddc81 --- /dev/null +++ b/samples/xml/calendar_query_single.xml @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="UTF-8"?> +<D:multistatus xmlns:D="DAV:"> + <D:response> + <D:href>event.ics</D:href> + <D:propstat> + <D:status>HTTP/1.1 200 OK</D:status> + <D:prop> + <D:getetag>"63475566792"</D:getetag> + <C:calendar-data xmlns:C="urn:ietf:params:xml:ns:caldav">BEGIN:VCALENDAR +PRODID:-//Google Inc//Google Calendar 70.9054//EN +VERSION:2.0 +CALSCALE:GREGORIAN +X-WR-CALNAME:calmozilla1@gmail.com +X-WR-TIMEZONE:America/Los_Angeles +BEGIN:VTIMEZONE +TZID:America/Los_Angeles +X-LIC-LOCATION:America/Los_Angeles +BEGIN:DAYLIGHT +TZOFFSETFROM:-0800 +TZOFFSETTO:-0700 +TZNAME:PDT +DTSTART:19700308T020000 +RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU +END:DAYLIGHT +BEGIN:STANDARD +TZOFFSETFROM:-0700 +TZOFFSETTO:-0800 +TZNAME:PST +DTSTART:19701101T020000 +RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU +END:STANDARD +END:VTIMEZONE +BEGIN:VEVENT +DTSTART;TZID=America/Los_Angeles:20120611T060000 +DTEND;TZID=America/Los_Angeles:20120611T070000 +DTSTAMP:20120616T215312Z +UID:haielig5qqu7mqnnrbttusghf4@google.com +CREATED:20120616T215312Z +DESCRIPTION: +LAST-MODIFIED:20120616T215312Z +LOCATION: +SEQUENCE:0 +STATUS:CONFIRMED +SUMMARY:Foo +TRANSP:OPAQUE +BEGIN:VALARM +ACTION:EMAIL +DESCRIPTION:This is an event reminder +SUMMARY:Alarm notification +ATTENDEE:mailto:calmozilla1@gmail.com +TRIGGER:-P0DT0H30M0S +END:VALARM +BEGIN:VALARM +ACTION:DISPLAY +DESCRIPTION:This is an event reminder +TRIGGER:-P0DT0H30M0S +END:VALARM +END:VEVENT +END:VCALENDAR</C:calendar-data> + </D:prop> + </D:propstat> + </D:response> +</D:multistatus> diff --git a/test/caldav/ical_test.js b/test/caldav/ical_test.js index 61d6c07..702400f 100644 --- a/test/caldav/ical_test.js +++ b/test/caldav/ical_test.js @@ -3,6 +3,14 @@ testSupport.lib('ical'), suite('caldav/ics', function() { var ical; + var samples = {}; + + suiteSetup(function(done) { + testSupport.loadSample('ical/event.ics', function(err, data) { + samples.event = data; + done(); + }); + }); suiteSetup(function() { ical = Caldav.require('ical'); @@ -12,4 +20,17 @@ suite('caldav/ics', function() { assert.ok(ical); }); + suite('VEVENT', function() { + var result; + + setup(function() { + result = ical(samples.event); + }); + + test('parse', function() { + assert.ok(result.vevent); + }); + + }); + }); diff --git a/test/caldav/sax/dav_response_test.js b/test/caldav/sax/dav_response_test.js index 45bc788..b6032f8 100644 --- a/test/caldav/sax/dav_response_test.js +++ b/test/caldav/sax/dav_response_test.js @@ -1,8 +1,8 @@ testSupport.lib('responder'); testSupport.lib('sax'); testSupport.lib('sax/base'); -testSupport.lib('sax/dav_response'); testSupport.lib('ical'); +testSupport.lib('sax/dav_response'); suite('caldav/sax/dav_response', function() { @@ -28,7 +28,30 @@ suite('caldav/sax/dav_response', function() { subject.registerHandler('DAV:/response', Response); }); - suite('parsing', function() { + suite('calendar-query', function() { + var xml; + + testSupport.defineSample('xml/calendar_query_single.xml', function(data) { + xml = data; + }); + + test('result', function(done) { + subject.once('complete', function(data) { + var response = data.multistatus; + var event = response['event.ics']; + assert.ok(event); + + console.log(event); + assert.ok(event['calendar-data'].value); + assert.ok(event['calendar-data'].value.vevent); + done(); + }); + + subject.write(xml).close(); + }); + }); + + suite('propget', function() { var xml; testSupport.defineSample('xml/propget.xml', function(data) { |