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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/*
* dialog_methods.js
*/
(function($) {
module("dialog: methods", {
teardown: function() {
$("body>.ui-dialog").remove();
}
});
test("init", function() {
expect(7);
$("<div></div>").appendTo('body').dialog().remove();
ok(true, '.dialog() called on element');
$([]).dialog().remove();
ok(true, '.dialog() called on empty collection');
$('<div></div>').dialog().remove();
ok(true, '.dialog() called on disconnected DOMElement - never connected');
$('<div></div>').appendTo('body').remove().dialog().remove();
ok(true, '.dialog() called on disconnected DOMElement - removed');
$('<div></div>').dialog().dialog("foo").remove();
ok(true, 'arbitrary method called after init');
el = $('<div></div>').dialog();
var foo = el.data("foo.dialog");
el.remove();
ok(true, 'arbitrary option getter after init');
$('<div></div>').dialog().data("foo.dialog", "bar").remove();
ok(true, 'arbitrary option setter after init');
});
test("destroy", function() {
expect(7);
$("<div></div>").appendTo('body').dialog().dialog("destroy").remove();
ok(true, '.dialog("destroy") called on element');
$([]).dialog().dialog("destroy").remove();
ok(true, '.dialog("destroy") called on empty collection');
$('<div></div>').dialog().dialog("destroy").remove();
ok(true, '.dialog("destroy") called on disconnected DOMElement');
$('<div></div>').dialog().dialog("destroy").dialog("foo").remove();
ok(true, 'arbitrary method called after destroy');
el = $('<div></div>').dialog();
var foo = el.dialog("destroy").data("foo.dialog");
el.remove();
ok(true, 'arbitrary option getter after destroy');
$('<div></div>').dialog().dialog("destroy").data("foo.dialog", "bar").remove();
ok(true, 'arbitrary option setter after destroy');
var expected = $('<div></div>').dialog(),
actual = expected.dialog('destroy');
equals(actual, expected, 'destroy is chainable');
});
test("enable", function() {
var expected = $('<div></div>').dialog(),
actual = expected.dialog('enable');
equals(actual, expected, 'enable is chainable');
el = $('<div></div>').dialog({ disabled: true });
el.dialog('enable');
equals(el.dialog('option', 'disabled'), false, 'enable method sets disabled option to false');
ok(!el.parents('.ui-dialog').hasClass('ui-dialog-disabled'), 'enable method removes ui-dialog-disabled class from ui-dialog element');
});
test("disable", function() {
var expected = $('<div></div>').dialog(),
actual = expected.dialog('disable');
equals(actual, expected, 'disable is chainable');
el = $('<div></div>').dialog({ disabled: false });
el.dialog('disable');
equals(el.dialog('option', 'disabled'), true, 'disable method sets disabled option to true');
ok(el.parents('.ui-dialog').hasClass('ui-dialog-disabled'), 'disable method adds ui-dialog-disabled class to ui-dialog element');
});
test("close", function() {
var expected = $('<div></div>').dialog(),
actual = expected.dialog('close');
equals(actual, expected, 'close is chainable');
ok(false, 'missing test - untested code is broken code');
});
test("isOpen", function() {
expect(4);
el = $('<div></div>').dialog();
equals(el.dialog('isOpen'), true, "dialog is open after init");
el.dialog('close');
equals(el.dialog('isOpen'), false, "dialog is closed");
el.remove();
el = $('<div></div>').dialog({autoOpen: false});
equals(el.dialog('isOpen'), false, "dialog is closed after init");
el.dialog('open');
equals(el.dialog('isOpen'), true, "dialog is open");
el.remove();
});
test("moveToTop", function() {
var expected = $('<div></div>').dialog(),
actual = expected.dialog('moveToTop');
equals(actual, expected, 'moveToTop is chainable');
ok(false, 'missing test - untested code is broken code');
});
test("open", function() {
var expected = $('<div></div>').dialog(),
actual = expected.dialog('open');
equals(actual, expected, 'open is chainable');
ok(false, 'missing test - untested code is broken code');
});
})(jQuery);
|