diff options
author | Mike Sherov <mike.sherov@gmail.com> | 2012-11-03 16:17:16 -0400 |
---|---|---|
committer | Mike Sherov <mike.sherov@gmail.com> | 2012-11-03 16:17:16 -0400 |
commit | 3df9ea29e644a3dd6345161513dae5823d9b0460 (patch) | |
tree | 08bdc053f90d110cb4af39c4de464d92ad8142c6 /tests/unit/dialog/dialog_events.js | |
parent | 68ad80c2922daccba773a9adafe9fb5efcb129a2 (diff) | |
download | jquery-ui-3df9ea29e644a3dd6345161513dae5823d9b0460.tar.gz jquery-ui-3df9ea29e644a3dd6345161513dae5823d9b0460.zip |
Dev: remove globals from tests and moved test helpers to correct location - Fixed #8770 Dev: Remove globals and Standardize Test Suite
Diffstat (limited to 'tests/unit/dialog/dialog_events.js')
-rw-r--r-- | tests/unit/dialog/dialog_events.js | 238 |
1 files changed, 124 insertions, 114 deletions
diff --git a/tests/unit/dialog/dialog_events.js b/tests/unit/dialog/dialog_events.js index 38b75a714..c5090d8f6 100644 --- a/tests/unit/dialog/dialog_events.js +++ b/tests/unit/dialog/dialog_events.js @@ -8,7 +8,7 @@ module("dialog: events"); test("open", function() { expect(13); - el = $("<div></div>"); + var el = $("<div></div>"); el.dialog({ open: function(ev, ui) { ok(el.data("dialog")._isOpen, "interal _isOpen flag is set"); @@ -42,163 +42,171 @@ test("open", function() { test("dragStart", function() { expect(9); - el = $('<div></div>').dialog({ - dragStart: function(ev, ui) { - ok(true, 'dragging fires dragStart callback'); - equal(this, el[0], "context of callback"); - equal(ev.type, 'dialogdragstart', 'event type in callback'); + var handle, + el = $('<div></div>').dialog({ + dragStart: function(ev, ui) { + ok(true, 'dragging fires dragStart callback'); + equal(this, el[0], "context of callback"); + equal(ev.type, 'dialogdragstart', 'event type in callback'); + ok(ui.position !== undefined, "ui.position in callback"); + ok(ui.offset !== undefined, "ui.offset in callback"); + } + }).bind('dialogdragstart', function(ev, ui) { + ok(true, 'dragging fires dialogdragstart event'); + equal(this, el[0], 'context of event'); ok(ui.position !== undefined, "ui.position in callback"); ok(ui.offset !== undefined, "ui.offset in callback"); - } - }).bind('dialogdragstart', function(ev, ui) { - ok(true, 'dragging fires dialogdragstart event'); - equal(this, el[0], 'context of event'); - ok(ui.position !== undefined, "ui.position in callback"); - ok(ui.offset !== undefined, "ui.offset in callback"); - }); - var handle = $(".ui-dialog-titlebar", dlg()); - drag(handle, 50, 50); + }); + + handle = $(".ui-dialog-titlebar", el.dialog('widget')); + TestHelpers.dialog.drag(el, handle, 50, 50); el.remove(); }); test("drag", function() { expect(9); var handle, - hasDragged = false; + hasDragged = false, + el = $('<div></div>').dialog({ + drag: function(ev, ui) { + if (!hasDragged) { + ok(true, 'dragging fires drag callback'); + equal(this, el[0], "context of callback"); + equal(ev.type, 'dialogdrag', 'event type in callback'); + ok(ui.position !== undefined, "ui.position in callback"); + ok(ui.offset !== undefined, "ui.offset in callback"); - el = $('<div></div>').dialog({ - drag: function(ev, ui) { - if (!hasDragged) { - ok(true, 'dragging fires drag callback'); - equal(this, el[0], "context of callback"); - equal(ev.type, 'dialogdrag', 'event type in callback'); - ok(ui.position !== undefined, "ui.position in callback"); - ok(ui.offset !== undefined, "ui.offset in callback"); - - hasDragged = true; + hasDragged = true; + } } - } - }).one('dialogdrag', function(ev, ui) { - ok(true, 'dragging fires dialogdrag event'); - equal(this, el[0], 'context of event'); - ok(ui.position !== undefined, "ui.position in callback"); - ok(ui.offset !== undefined, "ui.offset in callback"); - }); - handle = $(".ui-dialog-titlebar", dlg()); - drag(handle, 50, 50); + }).one('dialogdrag', function(ev, ui) { + ok(true, 'dragging fires dialogdrag event'); + equal(this, el[0], 'context of event'); + ok(ui.position !== undefined, "ui.position in callback"); + ok(ui.offset !== undefined, "ui.offset in callback"); + }); + + handle = $(".ui-dialog-titlebar", el.dialog('widget')); + TestHelpers.dialog.drag(el, handle, 50, 50); el.remove(); }); test("dragStop", function() { expect(9); - el = $('<div></div>').dialog({ - dragStop: function(ev, ui) { - ok(true, 'dragging fires dragStop callback'); - equal(this, el[0], "context of callback"); - equal(ev.type, 'dialogdragstop', 'event type in callback'); + var handle, + el = $('<div></div>').dialog({ + dragStop: function(ev, ui) { + ok(true, 'dragging fires dragStop callback'); + equal(this, el[0], "context of callback"); + equal(ev.type, 'dialogdragstop', 'event type in callback'); + ok(ui.position !== undefined, "ui.position in callback"); + ok(ui.offset !== undefined, "ui.offset in callback"); + } + }).bind('dialogdragstop', function(ev, ui) { + ok(true, 'dragging fires dialogdragstop event'); + equal(this, el[0], 'context of event'); ok(ui.position !== undefined, "ui.position in callback"); ok(ui.offset !== undefined, "ui.offset in callback"); - } - }).bind('dialogdragstop', function(ev, ui) { - ok(true, 'dragging fires dialogdragstop event'); - equal(this, el[0], 'context of event'); - ok(ui.position !== undefined, "ui.position in callback"); - ok(ui.offset !== undefined, "ui.offset in callback"); - }); - var handle = $(".ui-dialog-titlebar", dlg()); - drag(handle, 50, 50); + }); + + handle = $(".ui-dialog-titlebar", el.dialog('widget')); + TestHelpers.dialog.drag(el, handle, 50, 50); el.remove(); }); test("resizeStart", function() { expect(13); - el = $('<div></div>').dialog({ - resizeStart: function(ev, ui) { - ok(true, 'resizing fires resizeStart callback'); - equal(this, el[0], "context of callback"); - equal(ev.type, 'dialogresizestart', 'event type in callback'); + var handle, + el = $('<div></div>').dialog({ + resizeStart: function(ev, ui) { + ok(true, 'resizing fires resizeStart callback'); + equal(this, el[0], "context of callback"); + equal(ev.type, 'dialogresizestart', 'event type in callback'); + ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); + ok(ui.originalSize !== undefined, "ui.originalSize in callback"); + ok(ui.position !== undefined, "ui.position in callback"); + ok(ui.size !== undefined, "ui.size in callback"); + } + }).bind('dialogresizestart', function(ev, ui) { + ok(true, 'resizing fires dialogresizestart event'); + equal(this, el[0], 'context of event'); ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); ok(ui.originalSize !== undefined, "ui.originalSize in callback"); ok(ui.position !== undefined, "ui.position in callback"); ok(ui.size !== undefined, "ui.size in callback"); - } - }).bind('dialogresizestart', function(ev, ui) { - ok(true, 'resizing fires dialogresizestart event'); - equal(this, el[0], 'context of event'); - ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); - ok(ui.originalSize !== undefined, "ui.originalSize in callback"); - ok(ui.position !== undefined, "ui.position in callback"); - ok(ui.size !== undefined, "ui.size in callback"); - }); - var handle = $(".ui-resizable-se", dlg()); - drag(handle, 50, 50); + }); + + handle = $(".ui-resizable-se", el.dialog('widget')); + TestHelpers.dialog.drag(el, handle, 50, 50); el.remove(); }); test("resize", function() { expect(13); var handle, - hasResized = false; - - el = $('<div></div>').dialog({ - resize: function(ev, ui) { - if (!hasResized) { - ok(true, 'resizing fires resize callback'); - equal(this, el[0], "context of callback"); - equal(ev.type, 'dialogresize', 'event type in callback'); - ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); - ok(ui.originalSize !== undefined, "ui.originalSize in callback"); - ok(ui.position !== undefined, "ui.position in callback"); - ok(ui.size !== undefined, "ui.size in callback"); + hasResized = false, + el = $('<div></div>').dialog({ + resize: function(ev, ui) { + if (!hasResized) { + ok(true, 'resizing fires resize callback'); + equal(this, el[0], "context of callback"); + equal(ev.type, 'dialogresize', 'event type in callback'); + ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); + ok(ui.originalSize !== undefined, "ui.originalSize in callback"); + ok(ui.position !== undefined, "ui.position in callback"); + ok(ui.size !== undefined, "ui.size in callback"); - hasResized = true; + hasResized = true; + } } - } - }).one('dialogresize', function(ev, ui) { - ok(true, 'resizing fires dialogresize event'); - equal(this, el[0], 'context of event'); - ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); - ok(ui.originalSize !== undefined, "ui.originalSize in callback"); - ok(ui.position !== undefined, "ui.position in callback"); - ok(ui.size !== undefined, "ui.size in callback"); - }); - handle = $(".ui-resizable-se", dlg()); - drag(handle, 50, 50); + }).one('dialogresize', function(ev, ui) { + ok(true, 'resizing fires dialogresize event'); + equal(this, el[0], 'context of event'); + ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); + ok(ui.originalSize !== undefined, "ui.originalSize in callback"); + ok(ui.position !== undefined, "ui.position in callback"); + ok(ui.size !== undefined, "ui.size in callback"); + }); + + handle = $(".ui-resizable-se", el.dialog('widget')); + TestHelpers.dialog.drag(el, handle, 50, 50); el.remove(); }); test("resizeStop", function() { expect(13); - el = $('<div></div>').dialog({ - resizeStop: function(ev, ui) { - ok(true, 'resizing fires resizeStop callback'); - equal(this, el[0], "context of callback"); - equal(ev.type, 'dialogresizestop', 'event type in callback'); - ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); - ok(ui.originalSize !== undefined, "ui.originalSize in callback"); - ok(ui.position !== undefined, "ui.position in callback"); - ok(ui.size !== undefined, "ui.size in callback"); - } - }).bind('dialogresizestop', function(ev, ui) { - ok(true, 'resizing fires dialogresizestop event'); - equal(this, el[0], 'context of event'); - ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); - ok(ui.originalSize !== undefined, "ui.originalSize in callback"); - ok(ui.position !== undefined, "ui.position in callback"); - ok(ui.size !== undefined, "ui.size in callback"); - }); - var handle = $(".ui-resizable-se", dlg()); - drag(handle, 50, 50); + var handle, + el = $('<div></div>').dialog({ + resizeStop: function(ev, ui) { + ok(true, 'resizing fires resizeStop callback'); + equal(this, el[0], "context of callback"); + equal(ev.type, 'dialogresizestop', 'event type in callback'); + ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); + ok(ui.originalSize !== undefined, "ui.originalSize in callback"); + ok(ui.position !== undefined, "ui.position in callback"); + ok(ui.size !== undefined, "ui.size in callback"); + } + }).bind('dialogresizestop', function(ev, ui) { + ok(true, 'resizing fires dialogresizestop event'); + equal(this, el[0], 'context of event'); + ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); + ok(ui.originalSize !== undefined, "ui.originalSize in callback"); + ok(ui.position !== undefined, "ui.position in callback"); + ok(ui.size !== undefined, "ui.size in callback"); + }); + + handle = $(".ui-resizable-se", el.dialog('widget')); + TestHelpers.dialog.drag(el, handle, 50, 50); el.remove(); }); asyncTest("close", function() { expect(14); - el = $('<div></div>').dialog({ + var el = $('<div></div>').dialog({ close: function(ev, ui) { ok(true, '.dialog("close") fires close callback'); equal(this, el[0], "context of callback"); @@ -234,7 +242,7 @@ asyncTest("close", function() { test("beforeClose", function() { expect(14); - el = $('<div></div>').dialog({ + var el = $('<div></div>').dialog({ beforeClose: function(ev, ui) { ok(true, '.dialog("close") fires beforeClose callback'); equal(this, el[0], "context of callback"); @@ -243,8 +251,9 @@ test("beforeClose", function() { return false; } }); + el.dialog('close'); - TestHelpers.isOpen('beforeClose callback should prevent dialog from closing'); + ok( el.dialog("widget").is(":visible"), 'beforeClose callback should prevent dialog from closing'); el.remove(); el = $('<div></div>').dialog(); @@ -256,7 +265,8 @@ test("beforeClose", function() { return false; }); el.dialog('close'); - TestHelpers.isOpen('beforeClose callback should prevent dialog from closing'); + + ok( el.dialog("widget").is(":visible"), 'beforeClose callback should prevent dialog from closing'); el.remove(); el = $('<div></div>').dialog().bind('dialogbeforeclose', function(ev, ui) { @@ -266,7 +276,7 @@ test("beforeClose", function() { return false; }); el.dialog('close'); - TestHelpers.isOpen('dialogbeforeclose event should prevent dialog from closing'); + ok( el.dialog("widget").is(":visible"), 'dialogbeforeclose event should prevent dialog from closing'); el.remove(); }); |