aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJames Lal <james@lightsofapollo.com>2012-06-27 16:58:05 +0200
committerJames Lal <james@lightsofapollo.com>2012-06-27 16:58:05 +0200
commit5e731c14d9fca4e99ac73f020d69008431ef4f81 (patch)
tree297270d9a71a242ae368f2e4303fbcb63a50ed23 /test
parent24932d09294ab7a80b9c00ff505bc2823f1a65d1 (diff)
downloadjsCalDAV-5e731c14d9fca4e99ac73f020d69008431ef4f81.tar.gz
working calendar queries
Diffstat (limited to 'test')
-rw-r--r--test/webcals/ical_test.js (renamed from test/webcals/ics_test.js)2
-rw-r--r--test/webcals/request/calendar_query_test.js23
-rw-r--r--test/webcals/request/propfind_test.js2
-rw-r--r--test/webcals/sax/dav_response_test.js2
-rw-r--r--test/webcals/templates/calendar_data_test.js9
-rw-r--r--test/webcals/templates/calendar_filter_test.js8
6 files changed, 30 insertions, 16 deletions
diff --git a/test/webcals/ics_test.js b/test/webcals/ical_test.js
index af1192e..ed9af4a 100644
--- a/test/webcals/ics_test.js
+++ b/test/webcals/ical_test.js
@@ -1,5 +1,5 @@
var fs = require('fs'),
- ics = requireLib('ics'),
+ ics = requireLib('ical'),
data = fs.readFileSync(__dirname + '/../../data/test.data', 'utf8');
suite('webcals/ics', function() {
diff --git a/test/webcals/request/calendar_query_test.js b/test/webcals/request/calendar_query_test.js
index f960e15..b1a167d 100644
--- a/test/webcals/request/calendar_query_test.js
+++ b/test/webcals/request/calendar_query_test.js
@@ -2,11 +2,12 @@ requireRequest();
requireLib('request/propfind');
requireLib('request/calendar_query');
-suite('webcals/request/propfind', function() {
+suite('webcals/request/calendar_query', function() {
var Propfind,
- CalendarData,
FakeXhr,
+ CalendarData,
CalendarQuery,
+ CalendarFilter,
Xhr,
Template,
oldXhrClass,
@@ -18,6 +19,7 @@ suite('webcals/request/propfind', function() {
suiteSetup(function() {
Propfind = Webcals.require('request/propfind');
CalendarData = Webcals.require('templates/calendar_data');
+ CalendarFilter = Webcals.require('templates/calendar_filter');
CalendarQuery = Webcals.require('request/calendar_query');
SaxResponse = Webcals.require('sax/dav_response');
FakeXhr = Webcals.require('support/fake_xhr');
@@ -44,13 +46,15 @@ suite('webcals/request/propfind', function() {
assert.equal(subject.xhr.method, 'REPORT');
assert.instanceOf(subject.fields, CalendarData);
+ assert.instanceOf(subject.filters, CalendarFilter);
});
test('#_createPayload', function() {
subject.prop('getetag');
subject.fields.select('VEVENT', ['NAME']);
+ subject.filters.add('VEVENT', true);
- var tags = [
+ var props = [
'<N0:getetag />',
'<N1:calendar-data>',
'<N1:comp name="VCALENDAR">',
@@ -61,12 +65,19 @@ suite('webcals/request/propfind', function() {
'</N1:calendar-data>'
].join('');
+ var filter = [
+ '<N1:comp-filter name="VCALENDAR">',
+ '<N1:comp-filter name="VEVENT" />',
+ '</N1:comp-filter>'
+ ].join('');
+
var expected = [
subject.template.doctype,
- '<N0:calendar-query xmlns:N0="DAV:" ',
+ '<N1:calendar-query xmlns:N0="DAV:" ',
'xmlns:N1="urn:ietf:params:xml:ns:caldav">',
- '<N0:prop>', tags, '</N0:prop>',
- '</N0:calendar-query>'
+ '<N0:prop>', props, '</N0:prop>',
+ '<N1:filter>', filter, '</N1:filter>',
+ '</N1:calendar-query>'
].join('');
assert.equal(subject._createPayload(), expected);
diff --git a/test/webcals/request/propfind_test.js b/test/webcals/request/propfind_test.js
index 6d2dbe7..1f152b0 100644
--- a/test/webcals/request/propfind_test.js
+++ b/test/webcals/request/propfind_test.js
@@ -72,8 +72,6 @@ suite('webcals/request/propfind', function() {
var result = subject._createPayload();
- console.log(result);
-
assert.equal(subject._createPayload(), expected);
});
diff --git a/test/webcals/sax/dav_response_test.js b/test/webcals/sax/dav_response_test.js
index 1279b84..f91fcef 100644
--- a/test/webcals/sax/dav_response_test.js
+++ b/test/webcals/sax/dav_response_test.js
@@ -1,6 +1,7 @@
requireLib('sax');
requireLib('sax/base');
requireLib('sax/dav_response');
+requireLib('ical');
suite('webcals/sax/dav_response', function() {
@@ -61,6 +62,7 @@ suite('webcals/sax/dav_response', function() {
value: {}
}
}
+
};
test('output', function(done) {
diff --git a/test/webcals/templates/calendar_data_test.js b/test/webcals/templates/calendar_data_test.js
index 5223f18..1828b39 100644
--- a/test/webcals/templates/calendar_data_test.js
+++ b/test/webcals/templates/calendar_data_test.js
@@ -52,11 +52,16 @@ suite('webcals/templates/calendar_data', function() {
'</N0:calendar-data>'
].join('');
- setup(function() {
- select();
+ test('without items', function() {
+ var output = subject.render(template);
+ assert.equal(
+ output,
+ '<N0:calendar-data />'
+ );
});
test('output', function() {
+ select();
var output = subject.render(template);
assert.equal(output, expected);
});
diff --git a/test/webcals/templates/calendar_filter_test.js b/test/webcals/templates/calendar_filter_test.js
index 517e78a..d79883b 100644
--- a/test/webcals/templates/calendar_filter_test.js
+++ b/test/webcals/templates/calendar_filter_test.js
@@ -1,7 +1,8 @@
requireRequest();
requireLib('templates/calendar_data');
+requireLib('templates/calendar_filter');
-suite('webcals/templates/calendar_data', function() {
+suite('webcals/templates/calendar_filter', function() {
var CalendarFilter;
var Template;
@@ -9,7 +10,7 @@ suite('webcals/templates/calendar_data', function() {
var template;
function filter() {
- subject.filter('VEVENT', true);
+ subject.add('VEVENT', true);
}
suiteSetup(function() {
@@ -44,9 +45,6 @@ suite('webcals/templates/calendar_data', function() {
test('output', function() {
var output = subject.render(template);
- console.log();
- console.log(output)
- console.log();
assert.equal(output, expected);
});
});