//\r
// Dialog Test Helper Functions\r
//\r
-var el, offsetBefore, offsetAfter, dragged;\r
+var el,\r
+ offsetBefore, offsetAfter,\r
+ heightBefore, heightAfter,\r
+ widthBefore, widthAfter,\r
+ dragged;\r
\r
var dlg = function() {\r
return el.data("dialog").element.parents(".ui-dialog:first");\r
}\r
\r
var drag = function(handle, dx, dy) {\r
- var element = el.data("dialog").element;\r
- offsetBefore = el.offset();\r
- $(handle).simulate("drag", {\r
+ var d = dlg();\r
+ offsetBefore = d.offset();\r
+ heightBefore = d.height();\r
+ widthBefore = d.width();\r
+ $(handle, d).simulate("drag", {\r
dx: dx || 0,\r
dy: dy || 0\r
});\r
dragged = { dx: dx, dy: dy };\r
- offsetAfter = el.offset();\r
+ offsetAfter = d.offset();\r
+ heightAfter = d.height();\r
+ widthAfter = d.width();\r
}\r
\r
var moved = function (dx, dy, msg) {\r
test("init", function() {\r
expect(6);\r
\r
- el = $("#dialog1").dialog();\r
+ $("#dialog1").dialog().remove();\r
ok(true, '.dialog() called on element');\r
\r
- $([]).dialog();\r
+ $([]).dialog().remove();\r
ok(true, '.dialog() called on empty collection');\r
\r
- $("<div/>").dialog();\r
+ $("<div/>").dialog().remove();\r
ok(true, '.dialog() called on disconnected DOMElement');\r
\r
- $("<div/>").dialog().dialog("foo");\r
+ $("<div/>").dialog().dialog("foo").remove();\r
ok(true, 'arbitrary method called after init');\r
\r
- $("<div/>").dialog().data("foo.dialog");\r
+ el = $("<div/>").dialog()\r
+ var foo = el.data("foo.dialog");\r
+ el.remove();\r
ok(true, 'arbitrary option getter after init');\r
\r
- $("<div/>").dialog().data("foo.dialog", "bar");\r
+ $("<div/>").dialog().data("foo.dialog", "bar").remove();\r
ok(true, 'arbitrary option setter after init');\r
-\r
});\r
\r
test("destroy", function() {\r
expect(6);\r
\r
- $("#dialog1").dialog().dialog("destroy"); \r
+ $("#dialog1").dialog().dialog("destroy").remove();\r
ok(true, '.dialog("destroy") called on element');\r
\r
- $([]).dialog().dialog("destroy");\r
+ $([]).dialog().dialog("destroy").remove();\r
ok(true, '.dialog("destroy") called on empty collection');\r
\r
- $("<div/>").dialog().dialog("destroy");\r
+ $("<div/>").dialog().dialog("destroy").remove();\r
ok(true, '.dialog("destroy") called on disconnected DOMElement');\r
\r
- $("<div/>").dialog().dialog("destroy").dialog("foo");\r
+ $("<div/>").dialog().dialog("destroy").dialog("foo").remove();\r
ok(true, 'arbitrary method called after destroy');\r
\r
- $("<div/>").dialog().dialog("destroy").data("foo.dialog");\r
+ el = $("<div/>").dialog();\r
+ var foo = el.dialog("destroy").data("foo.dialog");\r
+ el.remove();\r
ok(true, 'arbitrary option getter after destroy');\r
\r
- $("<div/>").dialog().dialog("destroy").data("foo.dialog", "bar");\r
+ $("<div/>").dialog().dialog("destroy").data("foo.dialog", "bar").remove();\r
ok(true, 'arbitrary option setter after destroy');\r
});\r
\r
});\r
equals(btn.parent().attr('className'), 'ui-dialog-buttonpane', "buttons in container");\r
btn.trigger("click");\r
+ el.remove();\r
});\r
\r
test("draggable", function() {\r
el.remove();\r
el = $("<div/>").dialog({ draggable: true });\r
shouldmove();\r
+ el.remove();\r
});\r
\r
-module("dialog: Methods");\r
+test("height", function() {\r
+ el = $("<div/>").dialog();\r
+ equals(dlg().height(), 200, "default height");\r
+ el.remove();\r
+ el = $("<div/>").dialog({ height: 437 });\r
+ equals(dlg().height(), 437, "default height");\r
+ el.remove();\r
+});\r
\r
-module("dialog: Callbacks");\r
+test("maxHeight", function() {\r
+ el = $("<div/>").dialog({ maxHeight: 400 });\r
+ drag('.ui-resizable-s', 1000, 1000);\r
+ equals(heightAfter, 400, "maxHeight");\r
+ el.remove();\r
+ el = $("<div/>").dialog({ maxHeight: 400 });\r
+ drag('.ui-resizable-n', -1000, -1000);\r
+ equals(heightAfter, 400, "maxHeight");\r
+ el.remove();\r
+});\r
\r
-module("dialog: Tickets");\r
+test("maxWidth", function() {\r
+ el = $("<div/>").dialog({ maxWidth: 400 });\r
+ drag('.ui-resizable-e', 1000, 1000);\r
+ equals(widthAfter, 400, "maxWidth");\r
+ el.remove();\r
+ el = $("<div/>").dialog({ maxWidth: 400 });\r
+ drag('.ui-resizable-w', -1000, -1000);\r
+ equals(widthAfter, 400, "maxWidth");\r
+ el.remove();\r
+});\r
+\r
+test("minHeight", function() {\r
+ el = $("<div/>").dialog({ minHeight: 10 });\r
+ drag('.ui-resizable-s', -1000, -1000);\r
+ equals(heightAfter, 10, "minHeight");\r
+ el.remove();\r
+ el = $("<div/>").dialog({ minHeight: 10 });\r
+ drag('.ui-resizable-n', 1000, 1000);\r
+ equals(heightAfter, 10, "minHeight");\r
+ el.remove();\r
+});\r
\r
-test("#XXXX title", function() {\r
- \r
- \r
- \r
+test("minWidth", function() {\r
+ el = $("<div/>").dialog({ minWidth: 10 });\r
+ drag('.ui-resizable-e', -1000, -1000);\r
+ equals(widthAfter, 10, "minWidth");\r
+ el.remove();\r
+ el = $("<div/>").dialog({ minWidth: 10 });\r
+ drag('.ui-resizable-w', 1000, 1000);\r
+ equals(widthAfter, 10, "minWidth");\r
+ el.remove();\r
});\r
\r
-module("dialog: Cleanup");\r
+module("dialog: Methods");\r
\r
-test("cleanup", function() {\r
+module("dialog: Callbacks");\r
\r
- $(".ui-dialog").remove();\r
+test("open", function() {\r
+ expect(4);\r
+ el = $("<span/>");\r
+ var content = el[0];\r
+ el.dialog({\r
+ open: function(ev, ui) {\r
+ ok(true, 'autoOpen: true fires open callback');\r
+ equals(this, content, "context of callback");\r
+ }\r
+ });\r
+ el.remove();\r
+ el = $("<span/>");\r
+ var content = el[0];\r
+ el.dialog({\r
+ autoOpen: false,\r
+ open: function(ev, ui) {\r
+ ok(true, '.dialog("open") fires open callback');\r
+ equals(this, el[0], "context of callback");\r
+ }\r
+ });\r
+ el.dialog("open");\r
+ el.remove();\r
+});\r
\r
+test("close", function() {\r
+ expect(2);\r
+ el = $("<div/>").dialog({\r
+ close: function(ev, ui) {\r
+ ok(true, '.dialog("close") fires close callback');\r
+ equals(this, el[0], "context of callback");\r
+ }\r
+ });\r
+ el.dialog("close");\r
+ el.remove();\r
});\r
+\r
+module("dialog: Tickets");\r