1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
requireRequest();
testSupport.lib('request/propfind');
testSupport.lib('request/calendar_home');
testSupport.helper('mock_request');
suite('caldav/request/propfind', function() {
var Connection;
var MockRequest;
var MockPropfind;
var Home;
var subject;
var con;
var url = 'http://google.com',
subject;
suiteSetup(function() {
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,
Propfind: MockPropfind
});
});
test('initialization', function() {
assert.equal(subject.url, url);
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/');
});
});
|