aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/dialog/dialog_events.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/dialog/dialog_events.js')
-rw-r--r--tests/unit/dialog/dialog_events.js170
1 files changed, 168 insertions, 2 deletions
diff --git a/tests/unit/dialog/dialog_events.js b/tests/unit/dialog/dialog_events.js
index bc88e9747..f5356979c 100644
--- a/tests/unit/dialog/dialog_events.js
+++ b/tests/unit/dialog/dialog_events.js
@@ -5,8 +5,174 @@
module("dialog: events");
-test("testname", function() {
- ok(false, "missing test - untested code is broken code.");
+test("open", function() {
+ expect(6);
+
+ el = $("<div></div>");
+ el.dialog({
+ open: function(ev, ui) {
+ ok(true, 'autoOpen: true fires open callback');
+ equals(this, el[0], "context of callback");
+ }
+ });
+ el.remove();
+
+ el = $("<div></div>");
+ el.dialog({
+ autoOpen: false,
+ open: function(ev, ui) {
+ ok(true, '.dialog("open") fires open callback');
+ equals(this, el[0], "context of callback");
+ }
+ });
+ el.dialog("open");
+ el.remove();
+
+ el = $('<div></div>').dialog({
+ autoOpen: false
+ });
+ el.bind('dialogopen', function(ev, ui) {
+ ok(true, 'dialog("open") fires open event');
+ equals(this, el[0], 'context of event');
+ });
+ el.dialog('open');
+ el.remove();
+});
+
+test("dragStart", function() {
+ expect(2);
+
+ el = $("<div></div>");
+ el.dialog({
+ dragStart: function(ev, ui) {
+ ok(true, 'dragging fires dragStart callback');
+ equals(this, el[0], "context of callback");
+ }
+ });
+ var handle = $(".ui-dialog-titlebar", dlg());
+ drag(handle, 50, 50);
+ el.remove();
+});
+
+test("drag", function() {
+ var fired = false;
+
+ el = $("<div></div>");
+ el.dialog({
+ drag: function(ev, ui) {
+ fired = true;
+ equals(this, el[0], "context of callback");
+ }
+ });
+ var handle = $(".ui-dialog-titlebar", dlg());
+ drag(handle, 50, 50);
+ ok(fired, "drag fired");
+ el.remove();
+});
+
+test("dragStop", function() {
+ expect(2);
+
+ el = $("<div></div>");
+ el.dialog({
+ dragStop: function(ev, ui) {
+ ok(true, 'dragging fires dragStop callback');
+ equals(this, el[0], "context of callback");
+ }
+ });
+ var handle = $(".ui-dialog-titlebar", dlg());
+ drag(handle, 50, 50);
+ el.remove();
+});
+
+test("resizeStart", function() {
+ expect(2);
+
+ el = $("<div></div>");
+ el.dialog({
+ resizeStart: function(ev, ui) {
+ ok(true, 'resizing fires resizeStart callback');
+ equals(this, el[0], "context of callback");
+ }
+ });
+ var handle = $(".ui-resizable-se", dlg());
+ drag(handle, 50, 50);
+ el.remove();
+});
+
+test("resize", function() {
+ var fired = false;
+
+ el = $("<div></div>");
+ el.dialog({
+ resize: function(ev, ui) {
+ fired = true;
+ equals(this, el[0], "context of callback");
+ }
+ });
+ var handle = $(".ui-resizable-se", dlg());
+ drag(handle, 50, 50);
+ ok(fired, "resize fired");
+ el.remove();
+});
+
+test("resizeStop", function() {
+ expect(2);
+
+ el = $("<div></div>");
+ el.dialog({
+ resizeStop: function(ev, ui) {
+ ok(true, 'resizing fires resizeStop callback');
+ equals(this, el[0], "context of callback");
+ }
+ });
+ var handle = $(".ui-resizable-se", dlg());
+ drag(handle, 50, 50);
+ el.remove();
+});
+
+test("close", function() {
+ expect(4);
+
+ el = $('<div></div>').dialog({
+ close: function(ev, ui) {
+ ok(true, '.dialog("close") fires close callback');
+ equals(this, el[0], "context of callback");
+ }
+ });
+ el.dialog("close");
+ el.remove();
+
+ el = $('<div></div>').dialog().bind('dialogclose', function(ev, ui) {
+ ok(true, '.dialog("close") fires dialogclose event');
+ equals(this, el[0], 'context of event');
+ });
+ el.dialog('close');
+ el.remove();
+});
+
+test("beforeclose", function() {
+ expect(6);
+
+ el = $('<div></div>').dialog({
+ beforeclose: function(ev, ui) {
+ ok(true, '.dialog("close") fires beforeclose callback');
+ equals(this, el[0], "context of callback");
+ return false;
+ }
+ });
+ el.dialog('close');
+ isOpen('beforeclose callback should prevent dialog from closing');
+ el.remove();
+
+ el = $('<div></div>').dialog().bind('dialogbeforeclose', function(ev, ui) {
+ ok(true, '.dialog("close") triggers dialogbeforeclose event');
+ equals(this, el[0], "context of event");
+ return false;
+ });
+ el.dialog('close');
+ isOpen('dialogbeforeclose event should prevent dialog from closing');
+ el.remove();
});
})(jQuery);