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
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function run_test() {
do_calendar_startup(really_run_test);
}
function really_run_test() {
test_freebusy();
test_period();
}
function test_freebusy() {
let icsService = Cc["@mozilla.org/calendar/ics-service;1"].getService(Ci.calIICSService);
// Bug 415987 - FREEBUSY decoding does not support comma-separated entries
// (https://bugzilla.mozilla.org/show_bug.cgi?id=415987)
let fbVal1 = "20080206T160000Z/PT1H";
let fbVal2 = "20080206T180000Z/PT1H";
let fbVal3 = "20080206T220000Z/PT1H";
let data =
"BEGIN:VCALENDAR\n" +
"BEGIN:VFREEBUSY\n" +
"FREEBUSY;FBTYPE=BUSY:" +
fbVal1 +
"," +
fbVal2 +
"," +
fbVal3 +
"\n" +
"END:VFREEBUSY\n" +
"END:VCALENDAR\n";
let fbComp = icsService.parseICS(data).getFirstSubcomponent("VFREEBUSY");
equal(fbComp.getFirstProperty("FREEBUSY").value, fbVal1);
equal(fbComp.getNextProperty("FREEBUSY").value, fbVal2);
equal(fbComp.getNextProperty("FREEBUSY").value, fbVal3);
}
function test_period() {
let period = Cc["@mozilla.org/calendar/period;1"].createInstance(Ci.calIPeriod);
period.start = cal.createDateTime("20120101T010101");
period.end = cal.createDateTime("20120101T010102");
equal(period.icalString, "20120101T010101/20120101T010102");
equal(period.duration.icalString, "PT1S");
period.icalString = "20120101T010103/20120101T010104";
equal(period.start.icalString, "20120101T010103");
equal(period.end.icalString, "20120101T010104");
equal(period.duration.icalString, "PT1S");
period.icalString = "20120101T010105/PT1S";
equal(period.start.icalString, "20120101T010105");
equal(period.end.icalString, "20120101T010106");
equal(period.duration.icalString, "PT1S");
period.makeImmutable();
// ical.js doesn't support immutability yet
// throws(
// () => {
// period.start = cal.createDateTime("20120202T020202");
// },
// /0x80460002/,
// "Object is Immutable"
// );
// throws(
// () => {
// period.end = cal.createDateTime("20120202T020202");
// },
// /0x80460002/,
// "Object is Immutable"
// );
let copy = period.clone();
equal(copy.start.icalString, "20120101T010105");
equal(copy.end.icalString, "20120101T010106");
equal(copy.duration.icalString, "PT1S");
copy.start.icalString = "20120101T010106";
copy.end = cal.createDateTime("20120101T010107");
equal(period.start.icalString, "20120101T010105");
equal(period.end.icalString, "20120101T010106");
equal(period.duration.icalString, "PT1S");
}
|