Debian Codegraph @

dojox/calendar/tests/unitTest_TimeRanges.js

raw symbols SCIP
1 define(["doh", "../Calendar"],
2 function(doh, Calendar){
3 doh.register("tests.unitTest_TimeRanges", [
4
5 /* Should work but does not. Unfortunately I don't have time to investigate why...
6 {
7 name: "TotoTest",
8 setUp: function(){
9 this.toto = 10;
10 },
11 tearDown: function(){
12 delete this.toto;
13 },
14 test1: function(){
15 doh.is(this.toto, 10);
16 },
17 test2: function(){
18 doh.is(this.toto, 10);
19 }
20 },*/
21
22 function test_DayInterval(doh){
23 var o = new Calendar();
24 var cal = o.dateModule;
25 var startDate = new Date(2011, 0, 5);
26 var res;
27
28 o.set("date", startDate);
29 o.set("dateInterval", "day");
30 o.set("dateIntervalSteps", 1);
31 o.validateRendering();
32 doh.is(cal.compare(o.get("date"), startDate), 0);
33
34 res = o._timeInterval;
35 doh.is(cal.compare(res[0], new Date(2011, 0, 5)), 0);
36 doh.is(cal.compare(res[1], new Date(2011, 0, 6)), 0);
37 o.destroyRecursive();
38 },
39
40 function test_MultiDayInterval(doh){
41 var o = new Calendar();
42 var cal = o.dateModule;
43 var startDate = new Date(2011, 0, 5);
44 var res;
45
46 o.set("date", startDate);
47 o.set("dateInterval", "day");
48 o.set("dateIntervalSteps", 3);
49 o.validateRendering();
50 doh.is(cal.compare(o.get("date"), startDate), 0);
51
52 res = o._timeInterval;
53 doh.is(cal.compare(res[0], new Date(2011, 0, 5)), 0);
54 doh.is(cal.compare(res[1], new Date(2011, 0, 8)), 0);
55 o.destroyRecursive();
56 },
57
58 function test_WeekInterval(doh){
59 var o = new Calendar({
60 firstDayOfWeek: 0 // do not depend on locale
61 });
62 var cal = o.dateModule;
63 var startDate = new Date(2011, 0, 5);
64 var res;
65
66 o.set("date", startDate);
67 o.set("dateInterval", "week");
68 o.set("dateIntervalSteps", 1);
69 o.validateRendering();
70 doh.is(cal.compare(o.get("date"), startDate), 0);
71
72 res = o._timeInterval;
73 doh.is(cal.compare(res[0], new Date(2011, 0, 2)), 0);
74 doh.is(cal.compare(res[1], new Date(2011, 0, 9)), 0);
75
76 o.set("firstDayOfWeek", 1);
77 o.validateRendering();
78 doh.is(cal.compare(o.get("date"), startDate), 0);
79
80 res = o._timeInterval;
81 doh.is(cal.compare(res[0], new Date(2011, 0, 3)), 0);
82 doh.is(cal.compare(res[1], new Date(2011, 0, 10)), 0);
83 o.destroyRecursive();
84 },
85
86 function test_MultiWeekInterval(doh){
87 var o = new Calendar({
88 firstDayOfWeek: 0 // do not depend on locale
89 });
90 var cal = o.dateModule;
91 var startDate = new Date(2011, 0, 5);
92 var res;
93
94 o.set("date", startDate);
95 o.set("dateInterval", "week");
96 o.set("dateIntervalSteps", 2);
97 o.validateRendering();
98 doh.is(cal.compare(o.get("date"), startDate), 0);
99
100 res = o._timeInterval;
101 doh.is(cal.compare(res[0], new Date(2011, 0, 2)), 0);
102 doh.is(cal.compare(res[1], new Date(2011, 0, 16)), 0);
103
104 o.set("firstDayOfWeek", 1);
105 o.validateRendering();
106 doh.is(cal.compare(o.get("date"), startDate), 0);
107
108 res = o._timeInterval;
109 doh.is(cal.compare(res[0], new Date(2011, 0, 3)), 0);
110 doh.is(cal.compare(res[1], new Date(2011, 0, 17)), 0);
111 o.destroyRecursive();
112 },
113
114 function test_MonthInterval(doh){
115 var o = new Calendar();
116 var cal = o.dateModule;
117 var startDate = new Date(2011, 0, 5);
118 var res;
119
120 o.set("date", startDate);
121 o.set("dateInterval", "month");
122 o.set("dateIntervalSteps", 1);
123 o.validateRendering();
124 doh.is(cal.compare(o.get("date"), startDate), 0);
125
126 res = o._timeInterval;
127 doh.is(cal.compare(res[0], new Date(2011, 0, 1)), 0);
128 doh.is(cal.compare(res[1], new Date(2011, 1, 1)), 0);
129 o.destroyRecursive();
130 },
131
132 function test_MultiMonthInterval(doh){
133 var o = new Calendar();
134 var cal = o.dateModule;
135 var startDate = new Date(2011, 0, 5);
136 var res;
137
138 o.set("date", startDate);
139 o.set("dateInterval", "month");
140 o.set("dateIntervalSteps", 2);
141 o.validateRendering();
142 doh.is(cal.compare(o.get("date"), startDate), 0);
143
144 res = o._timeInterval;
145 doh.is(cal.compare(res[0], new Date(2011, 0, 1)), 0);
146 doh.is(cal.compare(res[1], new Date(2011, 2, 1)), 0);
147 o.destroyRecursive();
148 }
149
150 ]);
151 });