diff options
author | James Lal <james@lightsofapollo.com> | 2012-07-06 14:52:13 -0700 |
---|---|---|
committer | James Lal <james@lightsofapollo.com> | 2012-07-06 14:52:13 -0700 |
commit | 684ec0e95608e3212d8dac1b2c7489cf7e5c3078 (patch) | |
tree | 15ff517b5715f4f32f44a70c2698caeb9426ee28 /test | |
parent | fa1bc078c2953c4d81d7c5c17e4f3a4c0e3febeb (diff) | |
download | jsCalDAV-684ec0e95608e3212d8dac1b2c7489cf7e5c3078.tar.gz |
Reworked requests to take connection object and options
Diffstat (limited to 'test')
-rw-r--r-- | test/caldav/request/abstract_test.js | 16 | ||||
-rw-r--r-- | test/caldav/request/calendar_query_test.js | 7 | ||||
-rw-r--r-- | test/caldav/request/propfind_test.js | 12 | ||||
-rw-r--r-- | test/helper.js | 1 |
4 files changed, 30 insertions, 6 deletions
diff --git a/test/caldav/request/abstract_test.js b/test/caldav/request/abstract_test.js index 6d74320..88d8b2b 100644 --- a/test/caldav/request/abstract_test.js +++ b/test/caldav/request/abstract_test.js @@ -4,11 +4,14 @@ suite('caldav/request/abstract.js', function() { var subject; var Abstract; var Xhr; + var Connection; + var con; var FakeXhr; var SAX; var oldXhrClass; var url = 'http://google.com/'; var options = { + url: url, configOpt: true }; @@ -17,6 +20,7 @@ suite('caldav/request/abstract.js', function() { FakeXhr = Caldav.require('support/fake_xhr'); Xhr = Caldav.require('xhr'); SAX = Caldav.require('sax'); + Connection = Caldav.require('connection'); oldXhrClass = Xhr.prototype.xhrClass; Xhr.prototype.xhrClass = FakeXhr; @@ -27,7 +31,11 @@ suite('caldav/request/abstract.js', function() { }); setup(function() { - subject = new Abstract(url, options); + con = new Connection({ + password: 'password', + user: 'user' + }); + subject = new Abstract(con, options); FakeXhr.instances.length = 0; }); @@ -39,14 +47,14 @@ suite('caldav/request/abstract.js', function() { assert.instanceOf(subject.xhr, Xhr); assert.equal(subject.xhr.url, url); assert.equal(subject.configOpt, options.configOpt); + assert.equal(subject.connection, con); assert.instanceOf(subject.sax, SAX); assert.equal(subject.xhr.headers['Content-Type'], 'text/xml'); }); test('xhr password options', function() { - var subject = new Abstract(url, { - password: 'password', - user: 'user' + var subject = new Abstract(con, { + url: url }); var xhr = subject.xhr; diff --git a/test/caldav/request/calendar_query_test.js b/test/caldav/request/calendar_query_test.js index 96a95af..e28940f 100644 --- a/test/caldav/request/calendar_query_test.js +++ b/test/caldav/request/calendar_query_test.js @@ -8,6 +8,8 @@ suite('caldav/request/calendar_query', function() { CalendarData, CalendarQuery, CalendarFilter, + Connection, + con, Xhr, Template, oldXhrClass, @@ -17,11 +19,13 @@ suite('caldav/request/calendar_query', function() { subject; suiteSetup(function() { + // this is way to much stuff Propfind = Caldav.require('request/propfind'); CalendarData = Caldav.require('templates/calendar_data'); CalendarFilter = Caldav.require('templates/calendar_filter'); CalendarQuery = Caldav.require('request/calendar_query'); SaxResponse = Caldav.require('sax/dav_response'); + Connection = Caldav.require('connection'); FakeXhr = Caldav.require('support/fake_xhr'); Template = Caldav.require('template'); Xhr = Caldav.require('xhr'); @@ -35,7 +39,8 @@ suite('caldav/request/calendar_query', function() { }); setup(function() { - subject = new CalendarQuery(url); + con = new Connection(); + subject = new CalendarQuery(con, { url: url }); FakeXhr.instances.length = 0; }); diff --git a/test/caldav/request/propfind_test.js b/test/caldav/request/propfind_test.js index 069aaf3..58677f4 100644 --- a/test/caldav/request/propfind_test.js +++ b/test/caldav/request/propfind_test.js @@ -5,7 +5,9 @@ suite('caldav/request/propfind', function() { var Abstract, Propfind, FakeXhr, + Connection, Xhr, + con, Template, oldXhrClass, SaxResponse; @@ -20,6 +22,7 @@ suite('caldav/request/propfind', function() { FakeXhr = Caldav.require('support/fake_xhr'); Template = Caldav.require('template'); Xhr = Caldav.require('xhr'); + Connection = Caldav.require('connection'); oldXhrClass = Xhr.prototype.xhrClass; Xhr.prototype.xhrClass = FakeXhr; @@ -30,7 +33,8 @@ suite('caldav/request/propfind', function() { }); setup(function() { - subject = new Propfind(url); + con = new Connection(); + subject = new Propfind(con, { url: url }); FakeXhr.instances.length = 0; }); @@ -55,6 +59,12 @@ suite('caldav/request/propfind', function() { assert.deepEqual(subject._props, [expected]); }); + test('.depth', function() { + subject.depth = 10; + assert.equal(subject.xhr.headers.Depth, 10); + assert.equal(subject.depth, 10); + }); + test('#_createPayload', function() { subject.prop('foo'); subject.prop('bar'); diff --git a/test/helper.js b/test/helper.js index 07ab837..6157bdb 100644 --- a/test/helper.js +++ b/test/helper.js @@ -130,6 +130,7 @@ requireRequest = function(callback) { testSupport.lib('responder'); testSupport.lib('xhr'); + testSupport.lib('connection'); testSupport.lib('sax'); testSupport.lib('sax/base'); testSupport.lib('sax/dav_response'); |