From 5e731c14d9fca4e99ac73f020d69008431ef4f81 Mon Sep 17 00:00:00 2001 From: James Lal Date: Wed, 27 Jun 2012 16:58:05 +0200 Subject: working calendar queries --- test/webcals/ical_test.js | 11 +++++++++++ test/webcals/ics_test.js | 11 ----------- test/webcals/request/calendar_query_test.js | 23 +++++++++++++++++------ test/webcals/request/propfind_test.js | 2 -- test/webcals/sax/dav_response_test.js | 2 ++ test/webcals/templates/calendar_data_test.js | 9 +++++++-- test/webcals/templates/calendar_filter_test.js | 8 +++----- 7 files changed, 40 insertions(+), 26 deletions(-) create mode 100644 test/webcals/ical_test.js delete mode 100644 test/webcals/ics_test.js (limited to 'test') diff --git a/test/webcals/ical_test.js b/test/webcals/ical_test.js new file mode 100644 index 0000000..ed9af4a --- /dev/null +++ b/test/webcals/ical_test.js @@ -0,0 +1,11 @@ +var fs = require('fs'), + ics = requireLib('ical'), + data = fs.readFileSync(__dirname + '/../../data/test.data', 'utf8'); + +suite('webcals/ics', function() { + + test('intiailizer', function() { + assert.ok(ics); + }); + +}); diff --git a/test/webcals/ics_test.js b/test/webcals/ics_test.js deleted file mode 100644 index af1192e..0000000 --- a/test/webcals/ics_test.js +++ /dev/null @@ -1,11 +0,0 @@ -var fs = require('fs'), - ics = requireLib('ics'), - data = fs.readFileSync(__dirname + '/../../data/test.data', 'utf8'); - -suite('webcals/ics', function() { - - test('intiailizer', function() { - assert.ok(ics); - }); - -}); 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 = [ '', '', '', @@ -61,12 +65,19 @@ suite('webcals/request/propfind', function() { '' ].join(''); + var filter = [ + '', + '', + '' + ].join(''); + var expected = [ subject.template.doctype, - '', - '', tags, '', - '' + '', props, '', + '', filter, '', + '' ].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() { '' ].join(''); - setup(function() { - select(); + test('without items', function() { + var output = subject.render(template); + assert.equal( + output, + '' + ); }); 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); }); }); -- cgit