|
4 | 4 |
|
5 | 5 | test("open", function(){
|
6 | 6 | expect(2);
|
7 |
| - |
| 7 | + |
8 | 8 | el = $("select").multiselect().multiselect("open");
|
9 | 9 | ok( el.multiselect("isOpen"), "isOpen parameter true" );
|
10 | 10 | equals( menu().css("display"), "block", "Test display CSS property" );
|
11 | 11 | el.multiselect("destroy");
|
12 | 12 | });
|
13 |
| - |
| 13 | + |
14 | 14 | test("close", function(){
|
15 | 15 | expect(2);
|
16 |
| - |
| 16 | + |
17 | 17 | el = $("select").multiselect().multiselect("open").multiselect("close");
|
18 | 18 | ok( !el.multiselect("isOpen"), "isOpen parameter false" );
|
19 | 19 | equals( menu().css("display"), "none", "Test display CSS property" );
|
20 | 20 | el.multiselect("destroy");
|
21 | 21 | });
|
22 |
| - |
| 22 | + |
23 | 23 | test("enable", function(){
|
24 | 24 | expect(2);
|
25 |
| - |
| 25 | + |
26 | 26 | el = $("select").multiselect().multiselect("disable").multiselect("enable");
|
27 | 27 | ok( button().is(":disabled") === false, "Button is enabled" );
|
28 | 28 | ok( el.is(":disabled") === false, "Original select is enabled" );
|
29 | 29 | el.multiselect("destroy");
|
30 | 30 | });
|
31 |
| - |
| 31 | + |
32 | 32 | test("disable", function(){
|
33 | 33 | expect(2);
|
34 |
| - |
| 34 | + |
35 | 35 | // clone this one so the original is not affected
|
36 | 36 | el = $("select").clone(true).appendTo(body).multiselect().multiselect("disable");
|
37 | 37 | ok( button().is(":disabled"), 'Button is disabled');
|
38 | 38 | ok( el.is(":disabled"), 'Original select is disabled');
|
39 | 39 | el.multiselect("destroy").remove();
|
40 | 40 | });
|
41 |
| - |
| 41 | + |
42 | 42 | test("enabling w/ pre-disabled tags (#216)", function(){
|
43 | 43 | expect(5);
|
44 |
| - |
| 44 | + |
45 | 45 | el = $('<select><option disabled value="foo">foo</option><option value="bar">bar</option>')
|
46 | 46 | .appendTo(document.body)
|
47 | 47 | .multiselect();
|
|
60 | 60 | equals(disabled.data(key), undefined, "and the option no longer has the stored data flag");
|
61 | 61 | el.multiselect("destroy").remove();
|
62 | 62 | });
|
63 |
| - |
| 63 | + |
64 | 64 | test("widget", function(){
|
65 | 65 | expect(1);
|
66 |
| - |
| 66 | + |
67 | 67 | el = $("select").multiselect();
|
68 | 68 | ok( menu().is("div.ui-multiselect-menu"), 'Widget is the menu element');
|
69 | 69 | el.multiselect("destroy");
|
70 | 70 | });
|
71 |
| - |
| 71 | + |
72 | 72 | test("getButton", function(){
|
73 | 73 | expect(1);
|
74 |
| - |
| 74 | + |
75 | 75 | el = $("select").multiselect();
|
76 | 76 | var button = el.multiselect("getButton");
|
77 | 77 | ok( button.is("button.ui-multiselect"), 'Button is the button element');
|
78 | 78 | el.multiselect("destroy");
|
79 | 79 | });
|
80 |
| - |
| 80 | + |
81 | 81 | test("checkAll", function(){
|
82 | 82 | expect(1);
|
83 |
| - |
| 83 | + |
84 | 84 | el = $("select").multiselect().multiselect("checkAll");
|
85 | 85 | var inputs = menu().find("input");
|
86 | 86 | ok( inputs.filter(":checked").length === inputs.length, 'All inputs selected on the widget?');
|
|
89 | 89 |
|
90 | 90 | test("uncheckAll", function(){
|
91 | 91 | expect(1);
|
92 |
| - |
| 92 | + |
93 | 93 | el = $("select").multiselect().multiselect("checkAll").multiselect("uncheckAll");
|
94 | 94 | ok( menu().find("input:checked").length === 0, 'All inputs unchecked on the widget?');
|
95 | 95 | el.multiselect("destroy");
|
96 | 96 | });
|
97 | 97 |
|
98 | 98 | test("isOpen", function(){
|
99 | 99 | expect(2);
|
100 |
| - |
| 100 | + |
101 | 101 | el = $("select").multiselect().multiselect("open");
|
102 | 102 | ok( el.multiselect("isOpen"), 'Testing isOpen method after calling open method');
|
103 | 103 | el = $("select").multiselect("close");
|
|
107 | 107 |
|
108 | 108 | test("destroy", function(){
|
109 | 109 | expect(2);
|
110 |
| - |
| 110 | + |
111 | 111 | el = $("select").multiselect().multiselect("destroy");
|
112 | 112 | ok( !$(".ui-multiselect").length , 'button.ui-multiselect removed from the DOM');
|
113 | 113 | ok( !el.data("multiselect") , 'no more multiselect obj attached to elem');
|
114 | 114 | });
|
115 | 115 |
|
116 | 116 | test("getChecked", function(){
|
117 | 117 | expect(2);
|
118 |
| - |
| 118 | + |
119 | 119 | el = $("select").multiselect().multiselect("checkAll");
|
120 | 120 | equals( el.multiselect("getChecked").length, 9, 'number of checkboxes returned after checking all and calling getChecked');
|
121 | 121 | el.multiselect("uncheckAll");
|
122 | 122 | equals( el.multiselect("getChecked").length, 0, 'number of checkboxes returned after unchecking all and calling getChecked');
|
123 | 123 | el.multiselect("destroy");
|
124 | 124 | });
|
125 |
| - |
| 125 | + |
126 | 126 | test("getUnchecked", function(){
|
127 | 127 | expect(2);
|
128 |
| - |
| 128 | + |
129 | 129 | el = $("select").multiselect().multiselect("checkAll");
|
130 | 130 | equals( el.multiselect("getUnchecked").length, 0, 'number of checkboxes returned after checking all and calling getUnchecked');
|
131 | 131 | el.multiselect("uncheckAll");
|
|
134 | 134 | });
|
135 | 135 |
|
136 | 136 | test("refresh", function(){
|
137 |
| - expect(4); |
138 |
| - |
| 137 | + expect(6); |
| 138 | + |
139 | 139 | el = $("select").clone().appendTo(body).multiselect();
|
140 |
| - el.empty().html('<option value="foo">foo</option><option value="bar">bar</option>'); |
| 140 | + el.empty().html('<option value="foo" data-testval=123>foo</option><option value="bar">bar</option>'); |
141 | 141 | el.multiselect('refresh');
|
142 |
| - |
| 142 | + |
143 | 143 | var checkboxes, getCheckboxes = (function hai(){
|
144 | 144 | checkboxes = menu().find('input[type="checkbox"]');
|
145 | 145 | return hai;
|
146 | 146 | })();
|
147 |
| - |
| 147 | + |
148 | 148 | equals( checkboxes.length, 2, "After clearing the select, adding 2 options, and refresh(), only 2 checkboxes exist");
|
149 | 149 | equals( checkboxes.eq(0).val(), 'foo', 'first is foo' );
|
150 |
| - equals( checkboxes.eq(1).val(), 'bar', 'second is foo' ); |
151 |
| - |
| 150 | + equals( checkboxes.eq(1).val(), 'bar', 'second is bar' ); |
| 151 | + |
152 | 152 | // add one more w/ append, just for safety's sake
|
153 |
| - el.append('<option value="baz">baz</option>'); |
| 153 | + el.append('<option value="baz" data-testval="something">baz</option>'); |
154 | 154 | el.multiselect('refresh');
|
155 | 155 | getCheckboxes();
|
156 |
| - equals( checkboxes.eq(2).val(), 'baz', 'after an append() call, the third option is now' ); |
157 |
| - |
| 156 | + equals( checkboxes.eq(2).val(), 'baz', 'after an append() call, the third option is now baz' ); |
| 157 | + equals($(el.multiselect("instance").inputs[0]).data().testval, 123, "the first input has the data attribute testval with value 123"); |
| 158 | + equals($(el.multiselect("instance").inputs[2]).data().testval, "something", "the third input has the data attribute testval with value something"); |
| 159 | + |
158 | 160 | el.multiselect("destroy").remove();
|
159 | 161 | });
|
160 | 162 |
|
|
0 commit comments