~jstys-z/helioviewer.org/timeline

« back to all changes in this revision

Viewing changes to lib/jquery/jquery.ui-1.6rc2/tests/dialog.js

  • Committer: V. Keith Hughitt
  • Date: 2009-03-26 19:20:57 UTC
  • Revision ID: hughitt1@kore-20090326192057-u0x8rf8sf5lmmnwh
nightly build 03-26-2009: Using alpha-channel JPEG 2000 dataset

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * dialog unit tests
3
 
 */
4
 
(function($) {
5
 
//
6
 
// Dialog Test Helper Functions
7
 
//
8
 
 
9
 
var defaults = {
10
 
        autoOpen: true,
11
 
        autoResize: true,
12
 
        buttons: {},
13
 
        disabled: false,
14
 
        dialogClass: null,
15
 
        draggable: true,
16
 
        height: 200,
17
 
        maxHeight: null,
18
 
        maxWidth: null,
19
 
        minHeight: 100,
20
 
        minWidth: 150,
21
 
        modal: false,
22
 
        overlay: {},
23
 
        position: 'center',
24
 
        resizable: true,
25
 
        stack: true,
26
 
        title: '',
27
 
        width: 300
28
 
};
29
 
 
30
 
var el,
31
 
        offsetBefore, offsetAfter,
32
 
        heightBefore, heightAfter,
33
 
        widthBefore, widthAfter,
34
 
        dragged;
35
 
 
36
 
function dlg() {
37
 
        return el.data("dialog").element.parents(".ui-dialog:first");
38
 
}
39
 
 
40
 
function isOpen(why) {
41
 
        ok(dlg().is(":visible"), why);
42
 
}
43
 
 
44
 
function isNotOpen(why) {
45
 
        ok(!dlg().is(":visible"), why);
46
 
}
47
 
 
48
 
function drag(handle, dx, dy) {
49
 
        var d = dlg();
50
 
        offsetBefore = d.offset();
51
 
        heightBefore = d.height();
52
 
        widthBefore = d.width();
53
 
        //this mouseover is to work around a limitation in resizable
54
 
        //TODO: fix resizable so handle doesn't require mouseover in order to be used
55
 
        $(handle, d).simulate("mouseover");
56
 
        $(handle, d).simulate("drag", {
57
 
                dx: dx || 0,
58
 
                dy: dy || 0
59
 
        });
60
 
        dragged = { dx: dx, dy: dy };
61
 
        offsetAfter = d.offset();
62
 
        heightAfter = d.height();
63
 
        widthAfter = d.width();
64
 
}
65
 
 
66
 
function moved(dx, dy, msg) {
67
 
        msg = msg ? msg + "." : "";
68
 
        var actual = { left: offsetAfter.left, top: offsetAfter.top };
69
 
        var expected = { left: offsetBefore.left + dx, top: offsetBefore.top + dy };
70
 
        compare2(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
71
 
}
72
 
 
73
 
function shouldmove(why) {
74
 
        var handle = $(".ui-dialog-titlebar", dlg());
75
 
        drag(handle, 50, 50);
76
 
        moved(50, 50, why);
77
 
}
78
 
 
79
 
function shouldnotmove(why) {
80
 
        var handle = $(".ui-dialog-titlebar", dlg());
81
 
        drag(handle, 50, 50);
82
 
        moved(0, 0, why);
83
 
}
84
 
 
85
 
function resized(dw, dh, msg) {
86
 
        msg = msg ? msg + "." : "";
87
 
        var actual = { width: widthAfter, height: heightAfter };
88
 
        var expected = { width: widthBefore + dw, height: heightBefore + dh };
89
 
        compare2(actual, expected, 'resized[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
90
 
}
91
 
 
92
 
function shouldresize(why) {
93
 
        var handle = $(".ui-resizable-se", dlg());
94
 
        drag(handle, 50, 50);
95
 
        resized(50, 50, why);
96
 
}
97
 
 
98
 
function shouldnotresize(why) {
99
 
        var handle = $(".ui-resizable-se", dlg());
100
 
        drag(handle, 50, 50);
101
 
        resized(0, 0, why);
102
 
}
103
 
 
104
 
function broder(el, side){
105
 
        return parseInt(el.css('border-' + side + '-width'), 10);
106
 
}
107
 
 
108
 
function margin(el, side) {
109
 
        return parseInt(el.css('margin-' + side), 10);
110
 
}
111
 
 
112
 
// Dialog Tests
113
 
module("dialog");
114
 
 
115
 
test("init", function() {
116
 
        expect(6);
117
 
        
118
 
        $("#dialog1").dialog().remove();
119
 
        ok(true, '.dialog() called on element');
120
 
        
121
 
        $([]).dialog().remove();
122
 
        ok(true, '.dialog() called on empty collection');
123
 
        
124
 
        $('<div/>').dialog().remove();
125
 
        ok(true, '.dialog() called on disconnected DOMElement');
126
 
        
127
 
        $('<div/>').dialog().dialog("foo").remove();
128
 
        ok(true, 'arbitrary method called after init');
129
 
        
130
 
        el = $('<div/>').dialog();
131
 
        var foo = el.data("foo.dialog");
132
 
        el.remove();
133
 
        ok(true, 'arbitrary option getter after init');
134
 
        
135
 
        $('<div/>').dialog().data("foo.dialog", "bar").remove();
136
 
        ok(true, 'arbitrary option setter after init');
137
 
});
138
 
 
139
 
test("destroy", function() {
140
 
        expect(6);
141
 
 
142
 
        $("#dialog1").dialog().dialog("destroy").remove();
143
 
        ok(true, '.dialog("destroy") called on element');
144
 
 
145
 
        $([]).dialog().dialog("destroy").remove();
146
 
        ok(true, '.dialog("destroy") called on empty collection');
147
 
 
148
 
        $('<div/>').dialog().dialog("destroy").remove();
149
 
        ok(true, '.dialog("destroy") called on disconnected DOMElement');
150
 
 
151
 
        $('<div/>').dialog().dialog("destroy").dialog("foo").remove();
152
 
        ok(true, 'arbitrary method called after destroy');
153
 
 
154
 
        el = $('<div/>').dialog();
155
 
        var foo = el.dialog("destroy").data("foo.dialog");
156
 
        el.remove();
157
 
        ok(true, 'arbitrary option getter after destroy');
158
 
 
159
 
        $('<div/>').dialog().dialog("destroy").data("foo.dialog", "bar").remove();
160
 
        ok(true, 'arbitrary option setter after destroy');
161
 
});
162
 
 
163
 
/*
164
 
//This one takes a while to run
165
 
 
166
 
test("element types", function() {
167
 
        var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form'
168
 
                + ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr'
169
 
                + ',acronym,code,samp,kbd,var,img,object,hr'
170
 
                + ',input,button,label,select,iframe').split(',');
171
 
 
172
 
        $.each(typeNames, function(i) {
173
 
                var typeName = typeNames[i];
174
 
                el = $(document.createElement(typeName)).appendTo('body');
175
 
                (typeName == 'table' && el.append("<tr><td>content</td></tr>"));
176
 
                el.dialog();
177
 
                ok(true, '$("&lt;' + typeName + '/&gt").dialog()');
178
 
                el.dialog("destroy");
179
 
                el.remove();
180
 
        });
181
 
});
182
 
 
183
 
*/
184
 
 
185
 
test("defaults", function() {
186
 
        el = $('<div/>').dialog();
187
 
        $.each(defaults, function(key, val) {
188
 
                var actual = el.data(key + ".dialog"), expected = val,
189
 
                        method = (expected && expected.constructor == Object) ?
190
 
                                compare2 : equals;
191
 
                method(actual, expected, key);
192
 
        });
193
 
        el.remove();
194
 
});
195
 
 
196
 
test("title id", function() {
197
 
        expect(3);
198
 
        
199
 
        var titleId;
200
 
        
201
 
        // reset the uuid so we know what values to expect
202
 
        $.ui.dialog.uuid = 0;
203
 
        
204
 
        el = $('<div/>').dialog();
205
 
        titleId = dlg().find('.ui-dialog-title').attr('id');
206
 
        equals(titleId, 'ui-dialog-title-1', 'auto-numbered title id');
207
 
        el.remove();
208
 
        
209
 
        el = $('<div/>').dialog();
210
 
        titleId = dlg().find('.ui-dialog-title').attr('id');
211
 
        equals(titleId, 'ui-dialog-title-2', 'auto-numbered title id');
212
 
        el.remove();
213
 
        
214
 
        el = $('<div id="foo"/>').dialog();
215
 
        titleId = dlg().find('.ui-dialog-title').attr('id');
216
 
        equals(titleId, 'ui-dialog-title-foo', 'carried over title id');
217
 
        el.remove();
218
 
});
219
 
 
220
 
module("dialog: Options");
221
 
 
222
 
test("autoOpen", function() {
223
 
        expect(2);
224
 
        
225
 
        el = $('<div/>').dialog({ autoOpen: false });
226
 
                isNotOpen('.dialog({ autoOpen: false })');
227
 
        el.remove();
228
 
        
229
 
        el = $('<div/>').dialog({ autoOpen: true });
230
 
                isOpen('.dialog({ autoOpen: true })');
231
 
        el.remove();
232
 
});
233
 
 
234
 
test("autoResize", function() {
235
 
        expect(2);
236
 
        
237
 
        var actual,
238
 
                before,
239
 
                expected,
240
 
                handle;
241
 
        
242
 
        el = $('<div>content<br>content<br>content<br>content<br>content</div>').dialog({ autoResize: false });
243
 
                expected = { height: el.height() };
244
 
                handle = $(".ui-resizable-se", dlg());
245
 
                drag(handle, 50, 50);
246
 
                actual = { height: el.height() };
247
 
                compare2(actual, expected, '.dialog({ autoResize: false })');
248
 
        el.remove();
249
 
        el = $('<div>content<br>content<br>content<br>content<br>content</div>').dialog({ autoResize: true });
250
 
                before = { width: el.width(), height: el.height() };
251
 
                handle = $(".ui-resizable-se", dlg());
252
 
                drag(handle, 50, 50);
253
 
                expected = { width: before.width + 50, height: before.height + 50 };
254
 
                actual = { width: el.width(), height: el.height() };
255
 
                compare2(actual, expected, '.dialog({ autoResize: true })');
256
 
        el.remove();
257
 
});
258
 
 
259
 
test("buttons", function() {
260
 
        expect(17);
261
 
        
262
 
        var buttons = {
263
 
                "Ok": function(ev, ui) {
264
 
                        ok(true, "button click fires callback");
265
 
                        equals(this, el[0], "context of callback");
266
 
                        equals(ev.target, btn[0], "event target");
267
 
                },
268
 
                "Cancel": function(ev, ui) {
269
 
                        ok(true, "button click fires callback");
270
 
                        equals(this, el[0], "context of callback");
271
 
                        equals(ev.target, btn[1], "event target");
272
 
                }
273
 
        };
274
 
        
275
 
        el = $('<div/>').dialog({ buttons: buttons });
276
 
        var btn = $("button", dlg());
277
 
        equals(btn.length, 2, "number of buttons");
278
 
        
279
 
        var i = 0;
280
 
        $.each(buttons, function(key, val) {
281
 
                equals(btn.eq(i).text(), key, "text of button " + (i+1));
282
 
                i++;
283
 
        });
284
 
        
285
 
        equals(btn.parent().attr('className'), 'ui-dialog-buttonpane', "buttons in container");
286
 
        btn.trigger("click");
287
 
        
288
 
        var newButtons = {
289
 
                "Close": function(ev, ui) {
290
 
                        ok(true, "button click fires callback");
291
 
                        equals(this, el[0], "context of callback");
292
 
                        equals(ev.target, btn[0], "event target");
293
 
                }
294
 
        };
295
 
        
296
 
        equals(el.data("buttons.dialog"), buttons, '.data("buttons.dialog") getter');
297
 
        el.data("buttons.dialog", newButtons);
298
 
        equals(el.data("buttons.dialog"), newButtons, '.data("buttons.dialog", ...) setter');
299
 
        
300
 
        btn = $("button", dlg());
301
 
        equals(btn.length, 1, "number of buttons after setter");
302
 
        btn.trigger('click');
303
 
        
304
 
        i = 0;
305
 
        $.each(newButtons, function(key, val) {
306
 
                equals(btn.eq(i).text(), key, "text of button " + (i+1));
307
 
                i += 1;
308
 
        });
309
 
        
310
 
        el.remove();
311
 
});
312
 
 
313
 
test("dialogClass", function() {
314
 
        expect(4);
315
 
        
316
 
        el = $('<div/>').dialog();
317
 
                equals(dlg().is(".foo"), false, 'dialogClass not specified. foo class added');
318
 
        el.remove();
319
 
        
320
 
        el = $('<div/>').dialog({ dialogClass: "foo" });
321
 
                equals(dlg().is(".foo"), true, 'dialogClass in init. foo class added');
322
 
        el.remove();
323
 
        
324
 
        el = $('<div/>').dialog({ dialogClass: "foo bar" });
325
 
                equals(dlg().is(".foo"), true, 'dialogClass in init, two classes. foo class added');
326
 
                equals(dlg().is(".bar"), true, 'dialogClass in init, two classes. bar class added');
327
 
        el.remove();
328
 
});
329
 
 
330
 
test("draggable", function() {
331
 
        expect(4);
332
 
        
333
 
        el = $('<div/>').dialog({ draggable: false });
334
 
                shouldnotmove();
335
 
                el.data('draggable.dialog', true);
336
 
                shouldmove();
337
 
        el.remove();
338
 
        
339
 
        el = $('<div/>').dialog({ draggable: true });
340
 
                shouldmove();
341
 
                el.data('draggable.dialog', false);
342
 
                shouldnotmove();
343
 
        el.remove();
344
 
});
345
 
 
346
 
test("height", function() {
347
 
        expect(3);
348
 
        
349
 
        el = $('<div/>').dialog();
350
 
                equals(dlg().height(), defaults.height, "default height");
351
 
        el.remove();
352
 
        
353
 
        el = $('<div/>').dialog({ height: 437 });
354
 
                equals(dlg().height(), 437, "explicit height");
355
 
        el.remove();
356
 
        
357
 
        el = $('<div/>').dialog();
358
 
                el.data('height.dialog', 438);
359
 
                equals(dlg().height(), 438, "explicit height set after init");
360
 
        el.remove();
361
 
});
362
 
 
363
 
test("maxHeight", function() {
364
 
        expect(3);
365
 
        
366
 
        el = $('<div/>').dialog({ maxHeight: 400 });
367
 
                drag('.ui-resizable-s', 1000, 1000);
368
 
                equals(heightAfter, 400, "maxHeight");
369
 
        el.remove();
370
 
        
371
 
        el = $('<div/>').dialog({ maxHeight: 400 });
372
 
                drag('.ui-resizable-n', -1000, -1000);
373
 
                equals(heightAfter, 400, "maxHeight");
374
 
        el.remove();
375
 
        
376
 
        el = $('<div/>').dialog({ maxHeight: 400 }).data('maxHeight.dialog', 600);
377
 
                drag('.ui-resizable-n', -1000, -1000);
378
 
                equals(heightAfter, 600, "maxHeight");
379
 
        el.remove();
380
 
});
381
 
 
382
 
test("maxWidth", function() {
383
 
        expect(3);
384
 
        
385
 
        el = $('<div/>').dialog({ maxWidth: 400 });
386
 
                drag('.ui-resizable-e', 1000, 1000);
387
 
                equals(widthAfter, 400, "maxWidth");
388
 
        el.remove();
389
 
        
390
 
        el = $('<div/>').dialog({ maxWidth: 400 });
391
 
                drag('.ui-resizable-w', -1000, -1000);
392
 
                equals(widthAfter, 400, "maxWidth");
393
 
        el.remove();
394
 
        
395
 
        el = $('<div/>').dialog({ maxWidth: 400 }).data('maxWidth.dialog', 600);
396
 
                drag('.ui-resizable-w', -1000, -1000);
397
 
                equals(widthAfter, 600, "maxWidth");
398
 
        el.remove();
399
 
});
400
 
 
401
 
test("minHeight", function() {
402
 
        expect(3);
403
 
        
404
 
        el = $('<div/>').dialog({ minHeight: 10 });
405
 
                drag('.ui-resizable-s', -1000, -1000);
406
 
                equals(heightAfter, 10, "minHeight");
407
 
        el.remove();
408
 
        
409
 
        el = $('<div/>').dialog({ minHeight: 10 });
410
 
                drag('.ui-resizable-n', 1000, 1000);
411
 
                equals(heightAfter, 10, "minHeight");
412
 
        el.remove();
413
 
        
414
 
        el = $('<div/>').dialog({ minHeight: 10 }).data('minHeight.dialog', 30);
415
 
                drag('.ui-resizable-n', 1000, 1000);
416
 
                equals(heightAfter, 30, "minHeight");
417
 
        el.remove();
418
 
});
419
 
 
420
 
test("minWidth", function() {
421
 
        expect(3);
422
 
        
423
 
        el = $('<div/>').dialog({ minWidth: 10 });
424
 
                drag('.ui-resizable-e', -1000, -1000);
425
 
                equals(widthAfter, 10, "minWidth");
426
 
        el.remove();
427
 
        
428
 
        el = $('<div/>').dialog({ minWidth: 10 });
429
 
                drag('.ui-resizable-w', 1000, 1000);
430
 
                equals(widthAfter, 10, "minWidth");
431
 
        el.remove();
432
 
        
433
 
        el = $('<div/>').dialog({ minWidth: 30 }).data('minWidth.dialog', 30);
434
 
                drag('.ui-resizable-w', 1000, 1000);
435
 
                equals(widthAfter, 30, "minWidth");
436
 
        el.remove();
437
 
});
438
 
 
439
 
test("modal", function() {
440
 
        ok(false, "missing test");
441
 
});
442
 
 
443
 
test("overlay", function() {
444
 
        ok(false, "missing test");
445
 
});
446
 
 
447
 
test("position", function() {
448
 
        ok(false, "missing test");
449
 
});
450
 
 
451
 
test("resizable", function() {
452
 
        expect(4);
453
 
        
454
 
        el = $('<div/>').dialog();
455
 
                shouldresize("[default]");
456
 
                el.data('resizable.dialog', false);
457
 
                shouldnotresize('disabled after init');
458
 
        el.remove();
459
 
        
460
 
        el = $('<div/>').dialog({ resizable: false });
461
 
                shouldnotresize("disabled in init options");
462
 
                el.data('resizable.dialog', true);
463
 
                shouldresize('enabled after init');
464
 
        el.remove();
465
 
});
466
 
 
467
 
test("stack", function() {
468
 
        ok(false, "missing test");
469
 
});
470
 
 
471
 
test("title", function() {
472
 
        expect(5);
473
 
        
474
 
        function titleText() {
475
 
                return dlg().find(".ui-dialog-title").html();
476
 
        }
477
 
        
478
 
        el = $('<div/>').dialog();
479
 
                equals(titleText(), "&nbsp;", "[default]");
480
 
        el.remove();
481
 
        
482
 
        el = $('<div title="foo"/>').dialog();
483
 
                equals(titleText(), "foo", "title in element attribute");
484
 
        el.remove();
485
 
        
486
 
        el = $('<div/>').dialog({ title: 'foo' });
487
 
                equals(titleText(), "foo", "title in init options");
488
 
        el.remove();
489
 
        
490
 
        el = $('<div title="foo"/>').dialog({ title: 'bar' });
491
 
                equals(titleText(), "bar", "title in init options should override title in element attribute");
492
 
        el.remove();
493
 
        
494
 
        el = $('<div/>').dialog().data('title.dialog', 'foo');
495
 
                equals(titleText(), 'foo', 'title after init');
496
 
        el.remove();
497
 
});
498
 
 
499
 
test("width", function() {
500
 
        expect(3);
501
 
        
502
 
        el = $('<div/>').dialog();
503
 
                equals(dlg().width(), defaults.width, "default width");
504
 
        el.remove();
505
 
        
506
 
        el = $('<div/>').dialog({width: 437 });
507
 
                equals(dlg().width(), 437, "explicit width");
508
 
                el.data('width.dialog', 438);
509
 
                equals(dlg().width(), 438, 'explicit width after init');
510
 
        el.remove();
511
 
});
512
 
 
513
 
module("dialog: Methods");
514
 
 
515
 
test("isOpen", function() {
516
 
        expect(4);
517
 
        
518
 
        el = $('<div/>').dialog();
519
 
        equals(el.dialog('isOpen'), true, "dialog is open after init");
520
 
        el.dialog('close');
521
 
        equals(el.dialog('isOpen'), false, "dialog is closed");
522
 
        el.remove();
523
 
        
524
 
        el = $('<div/>').dialog({autoOpen: false});
525
 
        equals(el.dialog('isOpen'), false, "dialog is closed after init");
526
 
        el.dialog('open');
527
 
        equals(el.dialog('isOpen'), true, "dialog is open");
528
 
        el.remove();
529
 
});
530
 
 
531
 
module("dialog: Callbacks");
532
 
 
533
 
test("open", function() {
534
 
        expect(4);
535
 
        el = $("<div/>");
536
 
        el.dialog({
537
 
                open: function(ev, ui) {
538
 
                        ok(true, 'autoOpen: true fires open callback');
539
 
                        equals(this, el[0], "context of callback");
540
 
                }
541
 
        });
542
 
        el.remove();
543
 
        el = $("<div/>");
544
 
        el.dialog({
545
 
                autoOpen: false,
546
 
                open: function(ev, ui) {
547
 
                        ok(true, '.dialog("open") fires open callback');
548
 
                        equals(this, el[0], "context of callback");
549
 
                }
550
 
        });
551
 
        el.dialog("open");
552
 
        el.remove();
553
 
});
554
 
 
555
 
test("dragStart", function() {
556
 
        expect(1);
557
 
        el = $("<div/>");
558
 
        el.dialog({
559
 
                dragStart: function(ev, ui) {
560
 
                        equals(this, el[0], "context of callback");
561
 
                }
562
 
        });
563
 
        var handle = $(".ui-dialog-titlebar", dlg());
564
 
        drag(handle, 50, 50);
565
 
        el.remove();
566
 
});
567
 
 
568
 
test("drag", function() {
569
 
        var fired = false;
570
 
        el = $("<div/>");
571
 
        el.dialog({
572
 
                drag: function(ev, ui) {
573
 
                        fired = true;
574
 
                        equals(this, el[0], "context of callback");
575
 
                }
576
 
        });
577
 
        var handle = $(".ui-dialog-titlebar", dlg());
578
 
        drag(handle, 50, 50);
579
 
        ok(fired, "resize fired");
580
 
        el.remove();
581
 
});
582
 
 
583
 
test("dragStop", function() {
584
 
        expect(1);
585
 
        el = $("<div/>");
586
 
        el.dialog({
587
 
                dragStop: function(ev, ui) {
588
 
                        equals(this, el[0], "context of callback");
589
 
                }
590
 
        });
591
 
        var handle = $(".ui-dialog-titlebar", dlg());
592
 
        drag(handle, 50, 50);
593
 
        el.remove();
594
 
});
595
 
 
596
 
test("resizeStart", function() {
597
 
        expect(1);
598
 
        el = $("<div/>");
599
 
        el.dialog({
600
 
                resizeStart: function(ev, ui) {
601
 
                        equals(this, el[0], "context of callback");
602
 
                }
603
 
        });
604
 
        var handle = $(".ui-resizable-se", dlg());
605
 
        drag(handle, 50, 50);
606
 
        el.remove();
607
 
});
608
 
 
609
 
test("resize", function() {
610
 
        var fired = false;
611
 
        el = $("<div/>");
612
 
        el.dialog({
613
 
                resize: function(ev, ui) {
614
 
                        fired = true;
615
 
                        equals(this, el[0], "context of callback");
616
 
                }
617
 
        });
618
 
        var handle = $(".ui-resizable-se", dlg());
619
 
        drag(handle, 50, 50);
620
 
        ok(fired, "resize fired");
621
 
        el.remove();
622
 
});
623
 
 
624
 
test("resizeStop", function() {
625
 
        expect(1);
626
 
        el = $("<div/>");
627
 
        el.dialog({
628
 
                resizeStop: function(ev, ui) {
629
 
                        equals(this, el[0], "context of callback");
630
 
                }
631
 
        });
632
 
        var handle = $(".ui-resizable-se", dlg());
633
 
        drag(handle, 50, 50);
634
 
        el.remove();
635
 
});
636
 
 
637
 
test("close", function() {
638
 
        expect(2);
639
 
        el = $('<div/>').dialog({
640
 
                close: function(ev, ui) {
641
 
                        ok(true, '.dialog("close") fires close callback');
642
 
                        equals(this, el[0], "context of callback");
643
 
                }
644
 
        });
645
 
        el.dialog("close");
646
 
        el.remove();
647
 
});
648
 
 
649
 
test("beforeclose", function() {
650
 
        expect(6);
651
 
        
652
 
        el = $('<div/>').dialog({
653
 
                beforeclose: function(ev, ui) {
654
 
                        ok(true, '.dialog("close") fires beforeclose callback');
655
 
                        equals(this, el[0], "context of callback");
656
 
                        return false;
657
 
                }
658
 
        });
659
 
        el.dialog('close');
660
 
        isOpen('beforeclose callback should prevent dialog from closing');
661
 
        el.remove();
662
 
        
663
 
        el = $('<div/>').dialog().bind('dialogbeforeclose', function(ev, ui) {
664
 
                ok(true, '.dialog("close") triggers dialogbeforeclose event');
665
 
                equals(this, el[0], "context of event");
666
 
                return false;
667
 
        });
668
 
        el.dialog('close');
669
 
        isOpen('dialogbeforeclose event should prevent dialog from closing');
670
 
        el.remove();
671
 
});
672
 
 
673
 
module("dialog: Tickets");
674
 
 
675
 
})(jQuery);