| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 /* 2 * droppable unit tests 3 */ 4 (function($) { 5 // 6 // Droppable Test Helper Functions 7 // 8 9 var defaults = { 10 accept: null, 11 activeClass: null, 12 cssNamespace: "ui", 13 disabled: false, 14 greedy: false, 15 hoverClass: null, 16 scope: "default", 17 tolerance: "intersect" 18 }; 19 20 var el, drg; 21 22 function shouldBeDroppable() { 23 ok(false, "missing test - should be droppable"); 24 } 25 26 function shouldNotBeDroppable() { 27 ok(false, "missing test - should not be droppable"); 28 } 29 30 // Droppable Tests 31 module("droppable"); 32 33 test("init", function() { 34 expect(6); 35 36 $("<div></div>").appendTo('body').droppable().remove(); 37 ok(true, '.droppable() called on element'); 38 39 $([]).droppable(); 40 ok(true, '.droppable() called on empty collection'); 41 42 $("<div></div>").droppable(); 43 ok(true, '.droppable() called on disconnected DOMElement'); 44 45 $("<div></div>").droppable().droppable("foo"); 46 ok(true, 'arbitrary method called after init'); 47 48 $("<div></div>").droppable().data("foo.droppable"); 49 ok(true, 'arbitrary option getter after init'); 50 51 $("<div></div>").droppable().data("foo.droppable", "bar"); 52 ok(true, 'arbitrary option setter after init'); 53 }); 54 55 test("destroy", function() { 56 expect(6); 57 58 $("<div></div>").appendTo('body').droppable().droppable("destroy").remove(); 59 ok(true, '.droppable("destroy") called on element'); 60 61 $([]).droppable().droppable("destroy"); 62 ok(true, '.droppable("destroy") called on empty collection'); 63 64 $("<div></div>").droppable().droppable("destroy"); 65 ok(true, '.droppable("destroy") called on disconnected DOMElement'); 66 67 $("<div></div>").droppable().droppable("destroy").droppable("foo"); 68 ok(true, 'arbitrary method called after destroy'); 69 70 $("<div></div>").droppable().droppable("destroy").data("foo.droppable"); 71 ok(true, 'arbitrary option getter after destroy'); 72 73 $("<div></div>").droppable().droppable("destroy").data("foo.droppable", "bar"); 74 ok(true, 'arbitrary option setter after destroy'); 75 }); 76 77 test("enable", function() { 78 expect(6); 79 el = $("#droppable1").droppable({ disabled: true }); 80 shouldNotBeDroppable(); 81 el.droppable("enable"); 82 shouldBeDroppable(); 83 equals(el.data("disabled.droppable"), false, "disabled.droppable getter"); 84 el.droppable("destroy"); 85 el.droppable({ disabled: true }); 86 shouldNotBeDroppable(); 87 el.data("disabled.droppable", false); 88 equals(el.data("disabled.droppable"), false, "disabled.droppable setter"); 89 shouldBeDroppable(); 90 }); 91 92 test("disable", function() { 93 expect(6); 94 el = $("#droppable1").droppable({ disabled: false }); 95 shouldBeDroppable(); 96 el.droppable("disable"); 97 shouldNotBeDroppable(); 98 equals(el.data("disabled.droppable"), true, "disabled.droppable getter"); 99 el.droppable("destroy"); 100 el.droppable({ disabled: false }); 101 shouldBeDroppable(); 102 el.data("disabled.droppable", true); 103 equals(el.data("disabled.droppable"), true, "disabled.droppable setter"); 104 shouldNotBeDroppable(); 105 }); 106 107 test("element types", function() { 108 var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form' 109 + ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr' 110 + ',acronym,code,samp,kbd,var,img,object,hr' 111 + ',input,button,label,select,iframe').split(','); 112 113 $.each(typeNames, function(i) { 114 var typeName = typeNames[i]; 115 el = $(document.createElement(typeName)).appendTo('body'); 116 (typeName == 'table' && el.append("<tr><td>content</td></tr>")); 117 el.droppable(); 118 shouldBeDroppable(); 119 el.droppable("destroy"); 120 el.remove(); 121 }); 122 }); 123 124 test("defaults", function() { 125 el = $("<div></div>").droppable(); 126 $.each(defaults, function(key, val) { 127 var actual = el.data(key + ".droppable"), expected = val; 128 same(actual, expected, key); 129 }); 130 el.remove(); 131 }); 132 133 test("option setting", function() { 134 // The plugin shouldn't modify an option value set by the user 135 $.each(defaults, function(key, val) { 136 el = $("<div></div>").droppable(); 137 el.data(key + ".droppable", val); 138 var actual = el.data(key + ".droppable"), expected = val; 139 same(actual, expected, key); 140 el.remove(); 141 }); 142 }); 143 144 module("droppable: Options"); 145 146 test("accept, selector", function() { 147 ok(false, "missing test"); 148 }); 149 150 test("accept, fn", function() { 151 ok(false, "missing test"); 152 }); 153 154 test("activeClass", function() { 155 ok(false, "missing test"); 156 }); 157 158 test("cssNamespace", function() { 159 //cssNamespace should be appended with '-droppable' and added as className 160 el = $("<div></div>").droppable({ cssNamespace: "ui" }); 161 equals(el[0].className, "ui-droppable"); 162 el.droppable("destroy"); 163 164 //no className should be added if cssNamepsace is null 165 el = $("<div></div>").droppable({ cssNamespace: null }); 166 equals(el[0].className, ""); 167 el.droppable("destroy"); 168 }); 169 170 test("greedy", function() { 171 ok(false, "missing test"); 172 }); 173 174 test("hoverClass", function() { 175 ok(false, "missing test"); 176 }); 177 178 test("scope", function() { 179 ok(false, "missing test"); 180 }); 181 182 test("tolerance, fit", function() { 183 ok(false, "missing test"); 184 }); 185 186 test("tolerance, intersect", function() { 187 ok(false, "missing test"); 188 }); 189 190 test("tolerance, pointer", function() { 191 ok(false, "missing test"); 192 }); 193 194 test("tolerance, touch", function() { 195 ok(false, "missing test"); 196 }); 197 198 module("droppable: Callbacks"); 199 200 test("activate", function() { 201 ok(false, "missing test"); 202 }); 203 204 test("deactivate", function() { 205 ok(false, "missing test"); 206 }); 207 208 test("over", function() { 209 ok(false, "missing test"); 210 }); 211 212 test("out", function() { 213 ok(false, "missing test"); 214 }); 215 216 test("drop", function() { 217 ok(false, "missing test"); 218 }); 219 220 module("droppable: Tickets"); 221 222 223 })(jQuery);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |