/[projects]/misc/horsensspejder-web/jquery/jquery-ui-1.10.3/tests/unit/datepicker/datepicker_core.js
ViewVC logotype

Contents of /misc/horsensspejder-web/jquery/jquery-ui-1.10.3/tests/unit/datepicker/datepicker_core.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2125 - (show annotations) (download) (as text)
Wed Mar 12 19:30:05 2014 UTC (10 years, 2 months ago) by torben
File MIME type: application/javascript
File size: 23302 byte(s)
initial import
1 /*
2 * datepicker_core.js
3 */
4
5 (function($) {
6
7 module("datepicker: core");
8
9 TestHelpers.testJshint( "datepicker" );
10
11 test("initialization - Reinitialization after body had been emptied.", function() {
12 expect( 1 );
13 var bodyContent = $("body").children(), inp = $("#inp");
14 $("#inp").datepicker();
15 $("body").empty().append(inp);
16 $("#inp").datepicker();
17 ok( $("#"+$.datepicker._mainDivId).length===1, "Datepicker container added" );
18 $("body").empty().append(bodyContent); // Returning to initial state for later tests
19 });
20
21 test( "widget method - empty collection", function() {
22 expect( 1 );
23 $( "#nonExist" ).datepicker(); // should create nothing
24 ok( !$( "#ui-datepicker-div" ).length, "Non init on empty collection" );
25 });
26
27 test("widget method", function() {
28 expect( 1 );
29 var actual = $("#inp").datepicker().datepicker("widget")[0];
30 deepEqual($("body > #ui-datepicker-div:last-child")[0], actual);
31 });
32
33 asyncTest("baseStructure", function() {
34 expect( 58 );
35 var header, title, table, thead, week, panel, inl, child,
36 inp = TestHelpers.datepicker.init("#inp"),
37 dp = $("#ui-datepicker-div");
38
39 function step1() {
40 inp[0].focus();
41 setTimeout(function() {
42 ok(dp.is(":visible"), "Structure - datepicker visible");
43 ok(!dp.is(".ui-datepicker-rtl"), "Structure - not right-to-left");
44 ok(!dp.is(".ui-datepicker-multi"), "Structure - not multi-month");
45 equal(dp.children().length, 2, "Structure - child count");
46
47 header = dp.children(":first");
48 ok(header.is("div.ui-datepicker-header"), "Structure - header division");
49 equal(header.children().length, 3, "Structure - header child count");
50 ok(header.children(":first").is("a.ui-datepicker-prev") && header.children(":first").html() !== "", "Structure - prev link");
51 ok(header.children(":eq(1)").is("a.ui-datepicker-next") && header.children(":eq(1)").html() !== "", "Structure - next link");
52
53 title = header.children(":last");
54 ok(title.is("div.ui-datepicker-title") && title.html() !== "","Structure - title division");
55 equal(title.children().length, 2, "Structure - title child count");
56 ok(title.children(":first").is("span.ui-datepicker-month") && title.children(":first").text() !== "", "Structure - month text");
57 ok(title.children(":last").is("span.ui-datepicker-year") && title.children(":last").text() !== "", "Structure - year text");
58
59 table = dp.children(":eq(1)");
60 ok(table.is("table.ui-datepicker-calendar"), "Structure - month table");
61 ok(table.children(":first").is("thead"), "Structure - month table thead");
62 thead = table.children(":first").children(":first");
63 ok(thead.is("tr"), "Structure - month table title row");
64 equal(thead.find("th").length, 7, "Structure - month table title cells");
65 ok(table.children(":eq(1)").is("tbody"), "Structure - month table body");
66 ok(table.children(":eq(1)").children("tr").length >= 4, "Structure - month table week count");
67 week = table.children(":eq(1)").children(":first");
68 ok(week.is("tr"), "Structure - month table week row");
69 equal(week.children().length, 7, "Structure - week child count");
70 ok(week.children(":first").is("td.ui-datepicker-week-end"), "Structure - month table first day cell");
71 ok(week.children(":last").is("td.ui-datepicker-week-end"), "Structure - month table second day cell");
72 inp.datepicker("hide").datepicker("destroy");
73
74 step2();
75 });
76 }
77
78 function step2() {
79 // Editable month/year and button panel
80 inp = TestHelpers.datepicker.init("#inp", {changeMonth: true, changeYear: true, showButtonPanel: true});
81 inp.focus();
82 setTimeout(function() {
83 title = dp.find("div.ui-datepicker-title");
84 ok(title.children(":first").is("select.ui-datepicker-month"), "Structure - month selector");
85 ok(title.children(":last").is("select.ui-datepicker-year"), "Structure - year selector");
86
87 panel = dp.children(":last");
88 ok(panel.is("div.ui-datepicker-buttonpane"), "Structure - button panel division");
89 equal(panel.children().length, 2, "Structure - button panel child count");
90 ok(panel.children(":first").is("button.ui-datepicker-current"), "Structure - today button");
91 ok(panel.children(":last").is("button.ui-datepicker-close"), "Structure - close button");
92 inp.datepicker("hide").datepicker("destroy");
93
94 step3();
95 });
96 }
97
98 function step3() {
99 // Multi-month 2
100 inp = TestHelpers.datepicker.init("#inp", {numberOfMonths: 2});
101 inp.focus();
102 setTimeout(function() {
103 ok(dp.is(".ui-datepicker-multi"), "Structure multi [2] - multi-month");
104 equal(dp.children().length, 3, "Structure multi [2] - child count");
105 child = dp.children(":first");
106 ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-first"), "Structure multi [2] - first month division");
107 child = dp.children(":eq(1)");
108 ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-last"), "Structure multi [2] - second month division");
109 child = dp.children(":eq(2)");
110 ok(child.is("div.ui-datepicker-row-break"), "Structure multi [2] - row break");
111 ok(dp.is(".ui-datepicker-multi-2"), "Structure multi [2] - multi-2");
112 inp.datepicker("hide").datepicker("destroy");
113
114 step4();
115 });
116 }
117
118 function step4() {
119 // Multi-month 3
120 inp = TestHelpers.datepicker.init("#inp", {numberOfMonths: 3});
121 inp.focus();
122 setTimeout(function() {
123 ok(dp.is(".ui-datepicker-multi-3"), "Structure multi [3] - multi-3");
124 ok(! dp.is(".ui-datepicker-multi-2"), "Structure multi [3] - Trac #6704");
125 inp.datepicker("hide").datepicker("destroy");
126
127 step5();
128 });
129 }
130
131 function step5() {
132 // Multi-month [2, 2]
133 inp = TestHelpers.datepicker.init("#inp", {numberOfMonths: [2, 2]});
134 inp.focus();
135 setTimeout(function() {
136 ok(dp.is(".ui-datepicker-multi"), "Structure multi - multi-month");
137 equal(dp.children().length, 6, "Structure multi [2,2] - child count");
138 child = dp.children(":first");
139 ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-first"), "Structure multi [2,2] - first month division");
140 child = dp.children(":eq(1)");
141 ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-last"), "Structure multi [2,2] - second month division");
142 child = dp.children(":eq(2)");
143 ok(child.is("div.ui-datepicker-row-break"), "Structure multi [2,2] - row break");
144 child = dp.children(":eq(3)");
145 ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-first"), "Structure multi [2,2] - third month division");
146 child = dp.children(":eq(4)");
147 ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-last"), "Structure multi [2,2] - fourth month division");
148 child = dp.children(":eq(5)");
149 ok(child.is("div.ui-datepicker-row-break"), "Structure multi [2,2] - row break");
150 inp.datepicker("hide").datepicker("destroy");
151
152 // Inline
153 inl = TestHelpers.datepicker.init("#inl");
154 dp = inl.children();
155 ok(dp.is(".ui-datepicker-inline"), "Structure inline - main div");
156 ok(!dp.is(".ui-datepicker-rtl"), "Structure inline - not right-to-left");
157 ok(!dp.is(".ui-datepicker-multi"), "Structure inline - not multi-month");
158 equal(dp.children().length, 2, "Structure inline - child count");
159 header = dp.children(":first");
160 ok(header.is("div.ui-datepicker-header"), "Structure inline - header division");
161 equal(header.children().length, 3, "Structure inline - header child count");
162 table = dp.children(":eq(1)");
163 ok(table.is("table.ui-datepicker-calendar"), "Structure inline - month table");
164 ok(table.children(":first").is("thead"), "Structure inline - month table thead");
165 ok(table.children(":eq(1)").is("tbody"), "Structure inline - month table body");
166 inl.datepicker("destroy");
167
168 // Inline multi-month
169 inl = TestHelpers.datepicker.init("#inl", {numberOfMonths: 2});
170 dp = inl.children();
171 ok(dp.is(".ui-datepicker-inline") && dp.is(".ui-datepicker-multi"), "Structure inline multi - main div");
172 equal(dp.children().length, 3, "Structure inline multi - child count");
173 child = dp.children(":first");
174 ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-first"), "Structure inline multi - first month division");
175 child = dp.children(":eq(1)");
176 ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-last"), "Structure inline multi - second month division");
177 child = dp.children(":eq(2)");
178 ok(child.is("div.ui-datepicker-row-break"), "Structure inline multi - row break");
179 inl.datepicker("destroy");
180
181 start();
182 });
183 }
184
185 step1();
186 });
187
188 test("customStructure", function() {
189 expect( 20 );
190 var header, panel, title, thead,
191 dp = $("#ui-datepicker-div"),
192 // Check right-to-left localisation
193 inp = TestHelpers.datepicker.init("#inp", $.datepicker.regional.he);
194 inp.datepicker( "option", "showButtonPanel", true);
195 inp.focus();
196 ok(dp.is(".ui-datepicker-rtl"), "Structure RTL - right-to-left");
197 header = dp.children(":first");
198 ok(header.is("div.ui-datepicker-header"), "Structure RTL - header division");
199 equal(header.children().length, 3, "Structure RTL - header child count");
200 ok(header.children(":first").is("a.ui-datepicker-next"), "Structure RTL - prev link");
201 ok(header.children(":eq(1)").is("a.ui-datepicker-prev"), "Structure RTL - next link");
202 panel = dp.children(":last");
203 ok(panel.is("div.ui-datepicker-buttonpane"), "Structure RTL - button division");
204 equal(panel.children().length, 2, "Structure RTL - button panel child count");
205 ok(panel.children(":first").is("button.ui-datepicker-close"), "Structure RTL - close button");
206 ok(panel.children(":last").is("button.ui-datepicker-current"), "Structure RTL - today button");
207 inp.datepicker("hide").datepicker("destroy");
208
209 // Hide prev/next
210 inp = TestHelpers.datepicker.init("#inp", {hideIfNoPrevNext: true, minDate: new Date(2008, 2 - 1, 4), maxDate: new Date(2008, 2 - 1, 14)});
211 inp.val("02/10/2008").focus();
212 header = dp.children(":first");
213 ok(header.is("div.ui-datepicker-header"), "Structure hide prev/next - header division");
214 equal(header.children().length, 1, "Structure hide prev/next - links child count");
215 ok(header.children(":first").is("div.ui-datepicker-title"), "Structure hide prev/next - title division");
216 inp.datepicker("hide").datepicker("destroy");
217
218 // Changeable Month with read-only year
219 inp = TestHelpers.datepicker.init("#inp", {changeMonth: true});
220 inp.focus();
221 title = dp.children(":first").children(":last");
222 equal(title.children().length, 2, "Structure changeable month - title child count");
223 ok(title.children(":first").is("select.ui-datepicker-month"), "Structure changeable month - month selector");
224 ok(title.children(":last").is("span.ui-datepicker-year"), "Structure changeable month - read-only year");
225 inp.datepicker("hide").datepicker("destroy");
226
227 // Changeable year with read-only month
228 inp = TestHelpers.datepicker.init("#inp", {changeYear: true});
229 inp.focus();
230 title = dp.children(":first").children(":last");
231 equal(title.children().length, 2, "Structure changeable year - title child count");
232 ok(title.children(":first").is("span.ui-datepicker-month"), "Structure changeable year - read-only month");
233 ok(title.children(":last").is("select.ui-datepicker-year"), "Structure changeable year - year selector");
234 inp.datepicker("hide").datepicker("destroy");
235
236 // Read-only first day of week
237 inp = TestHelpers.datepicker.init("#inp", {changeFirstDay: false});
238 inp.focus();
239 thead = dp.find(".ui-datepicker-calendar thead tr");
240 equal(thead.children().length, 7, "Structure read-only first day - thead child count");
241 equal(thead.find("a").length, 0, "Structure read-only first day - thead links count");
242 inp.datepicker("hide").datepicker("destroy");
243 });
244
245 test("keystrokes", function() {
246 expect( 26 );
247 var inp = TestHelpers.datepicker.init("#inp"),
248 date = new Date();
249 inp.val("").datepicker("show").
250 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
251 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke enter");
252 inp.val("02/04/2008").datepicker("show").
253 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
254 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4),
255 "Keystroke enter - preset");
256 inp.val("02/04/2008").datepicker("show").
257 simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.HOME}).
258 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
259 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+home");
260 inp.val("02/04/2008").datepicker("show").
261 simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.END});
262 ok(inp.datepicker("getDate") == null, "Keystroke ctrl+end");
263 inp.val("").datepicker("show").
264 simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
265 ok(inp.datepicker("getDate") == null, "Keystroke esc");
266 inp.val("02/04/2008").datepicker("show").
267 simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
268 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4),
269 "Keystroke esc - preset");
270 inp.val("02/04/2008").datepicker("show").
271 simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
272 simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
273 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4),
274 "Keystroke esc - abandoned");
275 // Moving by day or week
276 inp.val("").datepicker("show").
277 simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.LEFT}).
278 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
279 date.setDate(date.getDate() - 1);
280 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+left");
281 inp.val("").datepicker("show").
282 simulate("keydown", {keyCode: $.ui.keyCode.LEFT}).
283 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
284 date.setDate(date.getDate() + 1);
285 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke left");
286 inp.val("").datepicker("show").
287 simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.RIGHT}).
288 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
289 date.setDate(date.getDate() + 1);
290 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+right");
291 inp.val("").datepicker("show").
292 simulate("keydown", {keyCode: $.ui.keyCode.RIGHT}).
293 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
294 date.setDate(date.getDate() - 1);
295 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke right");
296 inp.val("").datepicker("show").
297 simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.UP}).
298 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
299 date.setDate(date.getDate() - 7);
300 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+up");
301 inp.val("").datepicker("show").
302 simulate("keydown", {keyCode: $.ui.keyCode.UP}).
303 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
304 date.setDate(date.getDate() + 7);
305 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke up");
306 inp.val("").datepicker("show").
307 simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.DOWN}).
308 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
309 date.setDate(date.getDate() + 7);
310 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+down");
311 inp.val("").datepicker("show").
312 simulate("keydown", {keyCode: $.ui.keyCode.DOWN}).
313 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
314 date.setDate(date.getDate() - 7);
315 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke down");
316 // Moving by month or year
317 inp.val("02/04/2008").datepicker("show").
318 simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}).
319 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
320 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 1 - 1, 4),
321 "Keystroke pgup");
322 inp.val("02/04/2008").datepicker("show").
323 simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}).
324 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
325 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 3 - 1, 4),
326 "Keystroke pgdn");
327 inp.val("02/04/2008").datepicker("show").
328 simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
329 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
330 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2007, 2 - 1, 4),
331 "Keystroke ctrl+pgup");
332 inp.val("02/04/2008").datepicker("show").
333 simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
334 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
335 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2009, 2 - 1, 4),
336 "Keystroke ctrl+pgdn");
337 // Check for moving to short months
338 inp.val("03/31/2008").datepicker("show").
339 simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}).
340 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
341 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 29),
342 "Keystroke pgup - Feb");
343 inp.val("01/30/2008").datepicker("show").
344 simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}).
345 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
346 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 29),
347 "Keystroke pgdn - Feb");
348 inp.val("02/29/2008").datepicker("show").
349 simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
350 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
351 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2007, 2 - 1, 28),
352 "Keystroke ctrl+pgup - Feb");
353 inp.val("02/29/2008").datepicker("show").
354 simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
355 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
356 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2009, 2 - 1, 28),
357 "Keystroke ctrl+pgdn - Feb");
358 // Goto current
359 inp.datepicker("option", {gotoCurrent: true}).
360 datepicker("hide").val("02/04/2008").datepicker("show").
361 simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}).
362 simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.HOME}).
363 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
364 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4),
365 "Keystroke ctrl+home");
366 // Change steps
367 inp.datepicker("option", {stepMonths: 2, gotoCurrent: false}).
368 datepicker("hide").val("02/04/2008").datepicker("show").
369 simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}).
370 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
371 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2007, 12 - 1, 4),
372 "Keystroke pgup step 2");
373 inp.val("02/04/2008").datepicker("show").
374 simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}).
375 simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
376 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 4 - 1, 4),
377 "Keystroke pgdn step 2");
378 });
379
380 test("mouse", function() {
381 expect( 15 );
382 var inl,
383 inp = TestHelpers.datepicker.init("#inp"),
384 dp = $("#ui-datepicker-div"),
385 date = new Date();
386 inp.val("").datepicker("show");
387 $(".ui-datepicker-calendar tbody a:contains(10)", dp).simulate("click", {});
388 date.setDate(10);
389 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Mouse click");
390 inp.val("02/04/2008").datepicker("show");
391 $(".ui-datepicker-calendar tbody a:contains(12)", dp).simulate("click", {});
392 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 12),
393 "Mouse click - preset");
394 inp.val("02/04/2008").datepicker("show");
395 inp.val("").datepicker("show");
396 $("button.ui-datepicker-close", dp).simulate("click", {});
397 ok(inp.datepicker("getDate") == null, "Mouse click - close");
398 inp.val("02/04/2008").datepicker("show");
399 $("button.ui-datepicker-close", dp).simulate("click", {});
400 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4),
401 "Mouse click - close + preset");
402 inp.val("02/04/2008").datepicker("show");
403 $("a.ui-datepicker-prev", dp).simulate("click", {});
404 $("button.ui-datepicker-close", dp).simulate("click", {});
405 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4),
406 "Mouse click - abandoned");
407 // Current/previous/next
408 inp.val("02/04/2008").datepicker("option", {showButtonPanel: true}).datepicker("show");
409 $(".ui-datepicker-current", dp).simulate("click", {});
410 $(".ui-datepicker-calendar tbody a:contains(14)", dp).simulate("click", {});
411 date.setDate(14);
412 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Mouse click - current");
413 inp.val("02/04/2008").datepicker("show");
414 $(".ui-datepicker-prev", dp).simulate("click");
415 $(".ui-datepicker-calendar tbody a:contains(16)", dp).simulate("click");
416 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 1 - 1, 16),
417 "Mouse click - previous");
418 inp.val("02/04/2008").datepicker("show");
419 $(".ui-datepicker-next", dp).simulate("click");
420 $(".ui-datepicker-calendar tbody a:contains(18)", dp).simulate("click");
421 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 3 - 1, 18),
422 "Mouse click - next");
423 // Previous/next with minimum/maximum
424 inp.datepicker("option", {minDate: new Date(2008, 2 - 1, 2),
425 maxDate: new Date(2008, 2 - 1, 26)}).val("02/04/2008").datepicker("show");
426 $(".ui-datepicker-prev", dp).simulate("click");
427 $(".ui-datepicker-calendar tbody a:contains(16)", dp).simulate("click");
428 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 16),
429 "Mouse click - previous + min/max");
430 inp.val("02/04/2008").datepicker("show");
431 $(".ui-datepicker-next", dp).simulate("click");
432 $(".ui-datepicker-calendar tbody a:contains(18)", dp).simulate("click");
433 TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 18),
434 "Mouse click - next + min/max");
435 // Inline
436 inl = TestHelpers.datepicker.init("#inl");
437 dp = $(".ui-datepicker-inline", inl);
438 date = new Date();
439 inl.datepicker("setDate", date);
440 $(".ui-datepicker-calendar tbody a:contains(10)", dp).simulate("click", {});
441 date.setDate(10);
442 TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), date, "Mouse click inline");
443 inl.datepicker("option", {showButtonPanel: true}).datepicker("setDate", new Date(2008, 2 - 1, 4));
444 $(".ui-datepicker-calendar tbody a:contains(12)", dp).simulate("click", {});
445 TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), new Date(2008, 2 - 1, 12), "Mouse click inline - preset");
446 inl.datepicker("option", {showButtonPanel: true});
447 $(".ui-datepicker-current", dp).simulate("click", {});
448 $(".ui-datepicker-calendar tbody a:contains(14)", dp).simulate("click", {});
449 date.setDate(14);
450 TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), date, "Mouse click inline - current");
451 inl.datepicker("setDate", new Date(2008, 2 - 1, 4));
452 $(".ui-datepicker-prev", dp).simulate("click");
453 $(".ui-datepicker-calendar tbody a:contains(16)", dp).simulate("click");
454 TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), new Date(2008, 1 - 1, 16),
455 "Mouse click inline - previous");
456 inl.datepicker("setDate", new Date(2008, 2 - 1, 4));
457 $(".ui-datepicker-next", dp).simulate("click");
458 $(".ui-datepicker-calendar tbody a:contains(18)", dp).simulate("click");
459 TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), new Date(2008, 3 - 1, 18),
460 "Mouse click inline - next");
461 });
462
463 })(jQuery);

  ViewVC Help
Powered by ViewVC 1.1.20