aboutsummaryrefslogtreecommitdiffstats
path: root/test/caldav/request/calendar_home_test.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/caldav/request/calendar_home_test.js')
-rw-r--r--test/caldav/request/calendar_home_test.js43
1 files changed, 40 insertions, 3 deletions
diff --git a/test/caldav/request/calendar_home_test.js b/test/caldav/request/calendar_home_test.js
index 525d407..6df65df 100644
--- a/test/caldav/request/calendar_home_test.js
+++ b/test/caldav/request/calendar_home_test.js
@@ -2,10 +2,12 @@ requireRequest();
testSupport.lib('request/propfind');
testSupport.lib('request/calendar_home');
+testSupport.helper('mock_request');
suite('caldav/request/propfind', function() {
- var Propfind;
var Connection;
+ var MockRequest;
+ var MockPropfind;
var Home;
var subject;
var con;
@@ -14,15 +16,22 @@ suite('caldav/request/propfind', function() {
subject;
suiteSetup(function() {
- Propfind = Caldav.require('request/propfind');
Connection = Caldav.require('connection');
Home = Caldav.require('request/calendar_home');
+ MockRequest = Caldav.require('support/mock_request');
+ });
+
+ suiteSetup(function() {
+ MockPropfind = MockRequest.create(['prop']);
});
setup(function() {
+ MockPropfind.reset();
+
con = new Connection();
subject = new Home(con, {
- url: url
+ url: url,
+ Propfind: MockPropfind
});
});
@@ -31,5 +40,33 @@ suite('caldav/request/propfind', function() {
assert.equal(subject.connection, con);
});
+ test('_findPrincipal', function() {
+ var err, data, response = {};
+
+ subject._findPrincipal(url, function() {
+ err = arguments[0];
+ data = arguments[1];
+ });
+
+ var req = MockPropfind.instances[0];
+ assert.equal(req.options.url, url);
+ assert.deepEqual(req.propCalls, [
+ ['current-user-principal'],
+ ['principal-URL']
+ ]);
+
+ response[url] = {
+ 'current-user-principal': {
+ status: '200',
+ value: 'foo.com/'
+ }
+ };
+
+ // respond to request
+ req.respond(null, response);
+
+ assert.equal(data, 'foo.com/');
+ });
+
});