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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
var debug = require('debug')('caldav:test:detailed');
var helper = require('./helper.js');
var Caldav = require('../../lib/caldav');
var assert = require('assert');
require('../support/ical.js');
suite('query', function() {
var calendars;
var con;
suiteSetup(function(done) {
if (!testEnv.homeUrl) {
helper.findEnvHome(done);
} else {
done();
}
});
suiteSetup(function(done) {
con = helper.connection();
var resources = new Caldav.Request.Resources(con, {
url: testEnv.homeUrl
});
resources.addResource('calendar', Caldav.Resources.Calendar);
resources.prop('displayname');
resources.prop('resourcetype');
// found calendar home find calendars.
resources.send(function(err, data) {
helper.log('calendars:', data, 'detailed');
helper.log('found calendars:', Object.keys(data.calendar));
calendars = data.calendar;
if (Object.keys(calendars).length < 1) {
console.error('No calendars');
helper.log('no calendars', true, 'fatal');
process.exit(0);
}
done();
});
});
function parseString(ical, callback) {
var event;
var exceptions = [];
var primary;
var build = new ICAL.ComponentParser();
//build.onevent = function() {
//}
//build.oncomplete = function() {
//callback(primary);
//}
}
test('limit query', function(done) {
var keys = Object.keys(calendars);
var cal = calendars[keys[0]];
var query = cal.createQuery();
var comp = query.filter.setComp('VCALENDAR').
comp('VEVENT');
comp.setTimeRange({
start: '20121001T000000Z',
end: '20131001T000000Z'
});
query.prop('getetag');
var comp = query.data.setComp('VCALENDAR');
var event = comp.comp('VEVENT');
event.prop([
'DTSTART',
'DTEND',
'SUMMARY',
'DESCRIPTION'
]);
query.send(function(err, data) {
var list = [];
for (var key in data) {
list.push({
url: key,
ical: data[key]['calendar-data'].value
});
}
list.forEach(function(item) {
console.log(item.url, item.ical);
});
done();
});
});
});
|