From 2a8494fc81177944453ab986d3272c2b55ed0b7a Mon Sep 17 00:00:00 2001 From: Kris Borchers Date: Wed, 30 Jan 2013 23:38:20 -0600 Subject: [PATCH] Dialog Tests: Cleanup el -> element --- tests/unit/dialog/dialog_core.js | 52 +-- tests/unit/dialog/dialog_deprecated.js | 30 +- tests/unit/dialog/dialog_events.js | 196 ++++++------ tests/unit/dialog/dialog_methods.js | 88 ++--- tests/unit/dialog/dialog_options.js | 388 +++++++++++------------ tests/unit/dialog/dialog_test_helpers.js | 18 +- 6 files changed, 386 insertions(+), 386 deletions(-) diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js index b488bd112..9292eca9f 100644 --- a/tests/unit/dialog/dialog_core.js +++ b/tests/unit/dialog/dialog_core.js @@ -10,26 +10,26 @@ test("title id", function() { expect(1); var titleId, - el = $("
").dialog(); + element = $("
").dialog(); - titleId = el.dialog("widget").find(".ui-dialog-title").attr("id"); + titleId = element.dialog("widget").find(".ui-dialog-title").attr("id"); ok( /ui-id-\d+$/.test( titleId ), "auto-numbered title id"); - el.remove(); + element.remove(); }); test( "ARIA", function() { expect( 4 ); - var el = $( "
" ).dialog(), - wrapper = el.dialog( "widget" ); + var element = $( "
" ).dialog(), + wrapper = element.dialog( "widget" ); equal( wrapper.attr( "role" ), "dialog", "dialog role" ); equal( wrapper.attr( "aria-labelledby" ), wrapper.find( ".ui-dialog-title" ).attr( "id" ) ); - equal( wrapper.attr( "aria-describedby" ), el.attr( "id" ), "aria-describedby added" ); - el.remove(); + equal( wrapper.attr( "aria-describedby" ), element.attr( "id" ), "aria-describedby added" ); + element.remove(); - el = $("

descriotion

").dialog(); - strictEqual( el.dialog( "widget" ).attr( "aria-describedby" ), undefined, "no aria-describedby added, as already present in markup" ); - el.remove(); + element = $("

descriotion

").dialog(); + strictEqual( element.dialog( "widget" ).attr( "aria-describedby" ), undefined, "no aria-describedby added, as already present in markup" ); + element.remove(); }); test("widget method", function() { @@ -41,7 +41,7 @@ test("widget method", function() { asyncTest( "focus tabbable", function() { expect( 5 ); - var el, + var element, options = { buttons: [{ text: "Ok", @@ -50,24 +50,24 @@ asyncTest( "focus tabbable", function() { }; function checkFocus( markup, options, testFn, next ) { - el = $( markup ).dialog( options ); + element = $( markup ).dialog( options ); setTimeout(function() { testFn(); - el.remove(); + element.remove(); setTimeout( next ); }); } function step1() { checkFocus( "
", options, function() { - equal( document.activeElement, el.find( "input" )[ 1 ], + equal( document.activeElement, element.find( "input" )[ 1 ], "1. first element inside the dialog matching [autofocus]" ); }, step2 ); } function step2() { checkFocus( "
", options, function() { - equal( document.activeElement, el.find( "input" )[ 0 ], + equal( document.activeElement, element.find( "input" )[ 0 ], "2. tabbable element inside the content element" ); }, step3 ); } @@ -75,7 +75,7 @@ asyncTest( "focus tabbable", function() { function step3() { checkFocus( "
text
", options, function() { equal( document.activeElement, - el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" )[ 0 ], + element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" )[ 0 ], "3. tabbable element inside the buttonpane" ); }, step4 ); } @@ -83,20 +83,20 @@ asyncTest( "focus tabbable", function() { function step4() { checkFocus( "
text
", {}, function() { equal( document.activeElement, - el.dialog( "widget" ).find( ".ui-dialog-titlebar .ui-dialog-titlebar-close" )[ 0 ], + element.dialog( "widget" ).find( ".ui-dialog-titlebar .ui-dialog-titlebar-close" )[ 0 ], "4. the close button" ); }, step5 ); } function step5() { - el = $( "
text
" ).dialog({ + element = $( "
text
" ).dialog({ autoOpen: false }); - el.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).hide(); - el.dialog( "open" ); + element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).hide(); + element.dialog( "open" ); setTimeout(function() { - equal( document.activeElement, el.parent()[ 0 ], "5. the dialog itself" ); - el.remove(); + equal( document.activeElement, element.parent()[ 0 ], "5. the dialog itself" ); + element.remove(); start(); }); } @@ -119,9 +119,9 @@ test( "#7960: resizable handles below modal overlays", function() { asyncTest( "Prevent tabbing out of dialogs", function() { expect( 3 ); - var el = $( "
" ).dialog(), - inputs = el.find( "input" ), - widget = el.dialog( "widget" )[ 0 ]; + var element = $( "
" ).dialog(), + inputs = element.find( "input" ), + widget = element.dialog( "widget" )[ 0 ]; function checkTab() { ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" ); @@ -134,7 +134,7 @@ asyncTest( "Prevent tabbing out of dialogs", function() { function checkShiftTab() { ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" ); - el.remove(); + element.remove(); setTimeout( start ); } diff --git a/tests/unit/dialog/dialog_deprecated.js b/tests/unit/dialog/dialog_deprecated.js index 57f360544..ff6284ea5 100644 --- a/tests/unit/dialog/dialog_deprecated.js +++ b/tests/unit/dialog/dialog_deprecated.js @@ -8,12 +8,12 @@ test( "position, right bottom on window w/array", function() { // Support: FF, IE7 var winWidth = $( window ).width(), winHeight = $( window ).height(), - el = $("
").dialog({ position: [ "right", "bottom" ] }), - dialog = el.dialog("widget"), + element = $("
").dialog({ position: [ "right", "bottom" ] }), + dialog = element.dialog("widget"), offset = dialog.offset(); closeEnough( offset.left, winWidth - dialog.outerWidth() + $( window ).scrollLeft(), 1, "offset left of right bottom on window w/array" ); closeEnough( offset.top, winHeight - dialog.outerHeight() + $( window ).scrollTop(), 1, "offset top of right bottom on window w/array" ); - el.remove(); + element.remove(); }); test( "position, right bottom on window", function() { @@ -24,40 +24,40 @@ test( "position, right bottom on window", function() { // Support: FF, IE7 var winWidth = $( window ).width(), winHeight = $( window ).height(), - el = $("
").dialog({ position: "right bottom" }), - dialog = el.dialog("widget"), + element = $("
").dialog({ position: "right bottom" }), + dialog = element.dialog("widget"), offset = dialog.offset(); closeEnough( offset.left, winWidth - dialog.outerWidth() + $( window ).scrollLeft(), 1, "offset left of right bottom on window" ); closeEnough( offset.top, winHeight - dialog.outerHeight() + $( window ).scrollTop(), 1, "offset top of right bottom on window" ); - el.remove(); + element.remove(); }); test("position, offset from top left w/array", function() { expect( 2 ); - var el = $("
").dialog({ position: [10, 10] }), - dialog = el.dialog("widget"), + var element = $("
").dialog({ position: [10, 10] }), + dialog = element.dialog("widget"), offset = dialog.offset(); closeEnough(offset.left, 10 + $(window).scrollLeft(), 1); closeEnough(offset.top, 10 + $(window).scrollTop(), 1); - el.remove(); + element.remove(); }); test("position, top on window", function() { expect( 2 ); - var el = $("
").dialog({ position: "top" }), - dialog = el.dialog("widget"), + var element = $("
").dialog({ position: "top" }), + dialog = element.dialog("widget"), offset = dialog.offset(); closeEnough(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft(), 1); closeEnough(offset.top, $(window).scrollTop(), 1); - el.remove(); + element.remove(); }); test("position, left on window", function() { expect( 2 ); - var el = $("
").dialog({ position: "left" }), - dialog = el.dialog("widget"), + var element = $("
").dialog({ position: "left" }), + dialog = element.dialog("widget"), offset = dialog.offset(); closeEnough(offset.left, 0, 1); closeEnough(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop(), 1); - el.remove(); + element.remove(); }); diff --git a/tests/unit/dialog/dialog_events.js b/tests/unit/dialog/dialog_events.js index 6de36a8ea..7bcd5673e 100644 --- a/tests/unit/dialog/dialog_events.js +++ b/tests/unit/dialog/dialog_events.js @@ -8,115 +8,115 @@ module("dialog: events"); test("open", function() { expect(13); - var el = $("
"); - el.dialog({ + var element = $("
"); + element.dialog({ open: function(ev, ui) { - ok(el.data("ui-dialog")._isOpen, "interal _isOpen flag is set"); + ok(element.data("ui-dialog")._isOpen, "interal _isOpen flag is set"); ok(true, "autoOpen: true fires open callback"); - equal(this, el[0], "context of callback"); + equal(this, element[0], "context of callback"); equal(ev.type, "dialogopen", "event type in callback"); deepEqual(ui, {}, "ui hash in callback"); } }); - el.remove(); + element.remove(); - el = $("
"); - el.dialog({ + element = $("
"); + element.dialog({ autoOpen: false, open: function(ev, ui) { ok(true, ".dialog('open') fires open callback"); - equal(this, el[0], "context of callback"); + equal(this, element[0], "context of callback"); equal(ev.type, "dialogopen", "event type in callback"); deepEqual(ui, {}, "ui hash in callback"); } }).bind("dialogopen", function(ev, ui) { - ok(el.data("ui-dialog")._isOpen, "interal _isOpen flag is set"); + ok(element.data("ui-dialog")._isOpen, "interal _isOpen flag is set"); ok(true, "dialog('open') fires open event"); - equal(this, el[0], "context of event"); + equal(this, element[0], "context of event"); deepEqual(ui, {}, "ui hash in event"); }); - el.dialog("open"); - el.remove(); + element.dialog("open"); + element.remove(); }); test( "focus", function() { expect( 5 ); - var el, other; - el = $("#dialog1").dialog({ + var element, other; + element = $("#dialog1").dialog({ autoOpen: false }); other = $("#dialog2").dialog({ autoOpen: false }); - el.one( "dialogopen", function() { + element.one( "dialogopen", function() { ok( true, "open, just once" ); }); - el.one( "dialogfocus", function() { + element.one( "dialogfocus", function() { ok( true, "focus on open" ); }); other.dialog( "open" ); - el.one( "dialogfocus", function() { + element.one( "dialogfocus", function() { ok( true, "when opening and already open and wasn't on top" ); }); other.dialog( "open" ); - el.dialog( "open" ); + element.dialog( "open" ); - el.one( "dialogfocus", function() { + element.one( "dialogfocus", function() { ok( true, "when calling moveToTop and wasn't on top" ); }); other.dialog( "moveToTop" ); - el.dialog( "moveToTop" ); + element.dialog( "moveToTop" ); - el.bind( "dialogfocus", function() { + element.bind( "dialogfocus", function() { ok( true, "when mousedown anywhere on the dialog and it wasn't on top" ); }); other.dialog( "moveToTop" ); - el.trigger( "mousedown" ); + element.trigger( "mousedown" ); // triggers just once when already on top - el.dialog( "open" ); - el.dialog( "moveToTop" ); - el.trigger( "mousedown" ); + element.dialog( "open" ); + element.dialog( "moveToTop" ); + element.trigger( "mousedown" ); - el.add( other ).remove(); + element.add( other ).remove(); }); test("dragStart", function() { expect(9); var handle, - el = $("
").dialog({ + element = $("
").dialog({ dragStart: function(ev, ui) { ok(true, "dragging fires dragStart callback"); - equal(this, el[0], "context of callback"); + equal(this, element[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"); + equal(this, element[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(); + handle = $(".ui-dialog-titlebar", element.dialog("widget")); + TestHelpers.dialog.drag(element, handle, 50, 50); + element.remove(); }); test("drag", function() { expect(9); var handle, hasDragged = false, - el = $("
").dialog({ + element = $("
").dialog({ drag: function(ev, ui) { if (!hasDragged) { ok(true, "dragging fires drag callback"); - equal(this, el[0], "context of callback"); + equal(this, element[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"); @@ -126,48 +126,48 @@ test("drag", function() { } }).one("dialogdrag", function(ev, ui) { ok(true, "dragging fires dialogdrag event"); - equal(this, el[0], "context of event"); + equal(this, element[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(); + handle = $(".ui-dialog-titlebar", element.dialog("widget")); + TestHelpers.dialog.drag(element, handle, 50, 50); + element.remove(); }); test("dragStop", function() { expect(9); var handle, - el = $("
").dialog({ + element = $("
").dialog({ dragStop: function(ev, ui) { ok(true, "dragging fires dragStop callback"); - equal(this, el[0], "context of callback"); + equal(this, element[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"); + equal(this, element[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(); + handle = $(".ui-dialog-titlebar", element.dialog("widget")); + TestHelpers.dialog.drag(element, handle, 50, 50); + element.remove(); }); test("resizeStart", function() { expect(13); var handle, - el = $("
").dialog({ + element = $("
").dialog({ resizeStart: function(ev, ui) { ok(true, "resizing fires resizeStart callback"); - equal(this, el[0], "context of callback"); + equal(this, element[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"); @@ -176,27 +176,27 @@ test("resizeStart", function() { } }).bind("dialogresizestart", function(ev, ui) { ok(true, "resizing fires dialogresizestart event"); - equal(this, el[0], "context of event"); + equal(this, element[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(); + handle = $(".ui-resizable-se", element.dialog("widget")); + TestHelpers.dialog.drag(element, handle, 50, 50); + element.remove(); }); test("resize", function() { expect(13); var handle, hasResized = false, - el = $("
").dialog({ + element = $("
").dialog({ resize: function(ev, ui) { if (!hasResized) { ok(true, "resizing fires resize callback"); - equal(this, el[0], "context of callback"); + equal(this, element[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"); @@ -208,26 +208,26 @@ test("resize", function() { } }).one("dialogresize", function(ev, ui) { ok(true, "resizing fires dialogresize event"); - equal(this, el[0], "context of event"); + equal(this, element[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(); + handle = $(".ui-resizable-se", element.dialog("widget")); + TestHelpers.dialog.drag(element, handle, 50, 50); + element.remove(); }); test("resizeStop", function() { expect(13); var handle, - el = $("
").dialog({ + element = $("
").dialog({ resizeStop: function(ev, ui) { ok(true, "resizing fires resizeStop callback"); - equal(this, el[0], "context of callback"); + equal(this, element[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"); @@ -236,107 +236,107 @@ test("resizeStop", function() { } }).bind("dialogresizestop", function(ev, ui) { ok(true, "resizing fires dialogresizestop event"); - equal(this, el[0], "context of event"); + equal(this, element[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(); + handle = $(".ui-resizable-se", element.dialog("widget")); + TestHelpers.dialog.drag(element, handle, 50, 50); + element.remove(); }); asyncTest("close", function() { expect(14); - var el = $("
").dialog({ + var element = $("
").dialog({ close: function(ev, ui) { ok(true, ".dialog('close') fires close callback"); - equal(this, el[0], "context of callback"); + equal(this, element[0], "context of callback"); equal(ev.type, "dialogclose", "event type in callback"); deepEqual(ui, {}, "ui hash in callback"); } }).bind("dialogclose", function(ev, ui) { ok(true, ".dialog('close') fires dialogclose event"); - equal(this, el[0], "context of event"); + equal(this, element[0], "context of event"); deepEqual(ui, {}, "ui hash in event"); }); - el.dialog("close"); - el.remove(); + element.dialog("close"); + element.remove(); // Close event with an effect - el = $("
").dialog({ + element = $("
").dialog({ hide: 10, close: function(ev, ui) { ok(true, ".dialog('close') fires close callback"); - equal(this, el[0], "context of callback"); + equal(this, element[0], "context of callback"); equal(ev.type, "dialogclose", "event type in callback"); deepEqual(ui, {}, "ui hash in callback"); start(); } }).bind("dialogclose", function(ev, ui) { ok(true, ".dialog('close') fires dialogclose event"); - equal(this, el[0], "context of event"); + equal(this, element[0], "context of event"); deepEqual(ui, {}, "ui hash in event"); }); - el.dialog("close"); + element.dialog("close"); }); test("beforeClose", function() { expect(14); - var el = $("
").dialog({ + var element = $("
").dialog({ beforeClose: function(ev, ui) { ok(true, ".dialog('close') fires beforeClose callback"); - equal(this, el[0], "context of callback"); + equal(this, element[0], "context of callback"); equal(ev.type, "dialogbeforeclose", "event type in callback"); deepEqual(ui, {}, "ui hash in callback"); return false; } }); - el.dialog("close"); - ok( el.dialog("widget").is(":visible"), "beforeClose callback should prevent dialog from closing"); - el.remove(); + element.dialog("close"); + ok( element.dialog("widget").is(":visible"), "beforeClose callback should prevent dialog from closing"); + element.remove(); - el = $("
").dialog(); - el.dialog("option", "beforeClose", function(ev, ui) { + element = $("
").dialog(); + element.dialog("option", "beforeClose", function(ev, ui) { ok(true, ".dialog('close') fires beforeClose callback"); - equal(this, el[0], "context of callback"); + equal(this, element[0], "context of callback"); equal(ev.type, "dialogbeforeclose", "event type in callback"); deepEqual(ui, {}, "ui hash in callback"); return false; }); - el.dialog("close"); + element.dialog("close"); - ok( el.dialog("widget").is(":visible"), "beforeClose callback should prevent dialog from closing"); - el.remove(); + ok( element.dialog("widget").is(":visible"), "beforeClose callback should prevent dialog from closing"); + element.remove(); - el = $("
").dialog().bind("dialogbeforeclose", function(ev, ui) { + element = $("
").dialog().bind("dialogbeforeclose", function(ev, ui) { ok(true, ".dialog('close') triggers dialogbeforeclose event"); - equal(this, el[0], "context of event"); + equal(this, element[0], "context of event"); deepEqual(ui, {}, "ui hash in event"); return false; }); - el.dialog("close"); - ok( el.dialog("widget").is(":visible"), "dialogbeforeclose event should prevent dialog from closing"); - el.remove(); + element.dialog("close"); + ok( element.dialog("widget").is(":visible"), "dialogbeforeclose event should prevent dialog from closing"); + element.remove(); }); // #8789 and #8838 asyncTest("ensure dialog's container doesn't scroll on resize and focus", function() { expect(2); - var el = $("#dialog1").dialog(), + var element = $("#dialog1").dialog(), initialScroll = $(window).scrollTop(); - el.dialog("option", "height", 600); + element.dialog("option", "height", 600); equal($(window).scrollTop(), initialScroll, "scroll hasn't moved after height change"); setTimeout( function(){ $(".ui-dialog-titlebar-close").simulate("mousedown"); equal($(window).scrollTop(), initialScroll, "scroll hasn't moved after focus moved to dialog"); - el.dialog("destroy"); + element.dialog("destroy"); start(); }, 500); }); @@ -344,27 +344,27 @@ asyncTest("ensure dialog's container doesn't scroll on resize and focus", functi test("#5184: isOpen in dialogclose event is true", function() { expect( 3 ); - var el = $( "
" ).dialog({ + var element = $( "
" ).dialog({ close: function() { - ok( !el.dialog("isOpen"), "dialog is not open during close" ); + ok( !element.dialog("isOpen"), "dialog is not open during close" ); } }); - ok( el.dialog("isOpen"), "dialog is open after init" ); - el.dialog( "close" ); - ok( !el.dialog("isOpen"), "dialog is not open after close" ); - el.remove(); + ok( element.dialog("isOpen"), "dialog is open after init" ); + element.dialog( "close" ); + ok( !element.dialog("isOpen"), "dialog is not open after close" ); + element.remove(); }); test("ensure dialog keeps focus when clicking modal overlay", function() { expect( 2 ); - var el = $( "
" ).dialog({ + var element = $( "
" ).dialog({ modal: true }); ok( $(":focus").closest(".ui-dialog").length, "focus is in dialog" ); $(".ui-widget-overlay").simulate("mousedown"); ok( $(":focus").closest(".ui-dialog").length, "focus is still in dialog" ); - el.remove(); + element.remove(); }); })(jQuery); diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index efca71fd8..2c3495ca2 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -24,9 +24,9 @@ test("init", function() { $("
").appendTo("body").remove().dialog().remove(); ok(true, ".dialog() called on disconnected DOMElement - removed"); - var el = $("
").dialog(); - el.dialog("option", "foo"); - el.remove(); + var element = $("
").dialog(); + element.dialog("option", "foo"); + element.remove(); ok(true, "arbitrary option getter after init"); $("
").dialog().dialog("option", "foo", "bar").remove(); @@ -36,7 +36,7 @@ test("init", function() { test("destroy", function() { expect( 17 ); - var el, el2; + var element, element2; $( "#dialog1, #form-dialog" ).hide(); domEqual( "#dialog1", function() { @@ -65,17 +65,17 @@ test("destroy", function() { equal( $( ".ui-widget-overlay" ).length, 0, "overlay does not exist" ); equal( $.ui.dialog.overlayInstances, 0, "overlayInstances equals the number of open overlays"); - el = $( "#dialog1" ).dialog({ modal: true }), - el2 = $( "#dialog2" ).dialog({ modal: true }); + element = $( "#dialog1" ).dialog({ modal: true }), + element2 = $( "#dialog2" ).dialog({ modal: true }); equal( $( ".ui-widget-overlay" ).length, 2, "overlays created when dialogs are open" ); equal( $.ui.dialog.overlayInstances, 2, "overlayInstances equals the number of open overlays" ); - el.dialog( "close" ); + element.dialog( "close" ); equal( $( ".ui-widget-overlay" ).length, 1, "overlay remains after closing one dialog" ); equal( $.ui.dialog.overlayInstances, 1, "overlayInstances equals the number of open overlays" ); - el.dialog( "destroy" ); + element.dialog( "destroy" ); equal( $( ".ui-widget-overlay" ).length, 1, "overlay remains after destroying one dialog" ); equal( $.ui.dialog.overlayInstances, 1, "overlayInstances equals the number of open overlays" ); - el2.dialog( "destroy" ); + element2.dialog( "destroy" ); equal( $( ".ui-widget-overlay" ).length, 0, "overlays removed when all dialogs are destoryed" ); equal( $.ui.dialog.overlayInstances, 0, "overlayInstances equals the number of open overlays" ); }); @@ -102,40 +102,40 @@ test("#4980: Destroy should place element back in original DOM position", functi test( "enable/disable disabled", function() { expect( 2 ); - var el = $( "
" ).dialog(); - el.dialog( "disable" ); - equal(el.dialog( "option", "disabled" ), false, "disable method doesn't do anything" ); - ok( !el.dialog( "widget" ).hasClass( "ui-dialog-disabled" ), "disable method doesn't add ui-dialog-disabled class" ); + var element = $( "
" ).dialog(); + element.dialog( "disable" ); + equal(element.dialog( "option", "disabled" ), false, "disable method doesn't do anything" ); + ok( !element.dialog( "widget" ).hasClass( "ui-dialog-disabled" ), "disable method doesn't add ui-dialog-disabled class" ); }); test("close", function() { expect( 3 ); - var el, + var element, expected = $("
").dialog(), actual = expected.dialog("close"); equal(actual, expected, "close is chainable"); - el = $("
").dialog(); - ok(el.dialog("widget").is(":visible") && !el.dialog("widget").is(":hidden"), "dialog visible before close method called"); - el.dialog("close"); - ok(el.dialog("widget").is(":hidden") && !el.dialog("widget").is(":visible"), "dialog hidden after close method called"); + element = $("
").dialog(); + ok(element.dialog("widget").is(":visible") && !element.dialog("widget").is(":hidden"), "dialog visible before close method called"); + element.dialog("close"); + ok(element.dialog("widget").is(":hidden") && !element.dialog("widget").is(":visible"), "dialog hidden after close method called"); }); test("isOpen", function() { expect(4); - var el = $("
").dialog(); - equal(el.dialog("isOpen"), true, "dialog is open after init"); - el.dialog("close"); - equal(el.dialog("isOpen"), false, "dialog is closed"); - el.remove(); - - el = $("
").dialog({autoOpen: false}); - equal(el.dialog("isOpen"), false, "dialog is closed after init"); - el.dialog("open"); - equal(el.dialog("isOpen"), true, "dialog is open"); - el.remove(); + var element = $("
").dialog(); + equal(element.dialog("isOpen"), true, "dialog is open after init"); + element.dialog("close"); + equal(element.dialog("isOpen"), false, "dialog is closed"); + element.remove(); + + element = $("
").dialog({autoOpen: false}); + equal(element.dialog("isOpen"), false, "dialog is closed after init"); + element.dialog("open"); + equal(element.dialog("isOpen"), true, "dialog is open"); + element.remove(); }); test("moveToTop", function() { @@ -167,15 +167,15 @@ test("moveToTop", function() { test("open", function() { expect( 3 ); - var el, + var element, expected = $("
").dialog(), actual = expected.dialog("open"); equal(actual, expected, "open is chainable"); - el = $("
").dialog({ autoOpen: false }); - ok(el.dialog("widget").is(":hidden") && !el.dialog("widget").is(":visible"), "dialog hidden before open method called"); - el.dialog("open"); - ok(el.dialog("widget").is(":visible") && !el.dialog("widget").is(":hidden"), "dialog visible after open method called"); + element = $("
").dialog({ autoOpen: false }); + ok(element.dialog("widget").is(":hidden") && !element.dialog("widget").is(":visible"), "dialog hidden before open method called"); + element.dialog("open"); + ok(element.dialog("widget").is(":visible") && !element.dialog("widget").is(":hidden"), "dialog visible after open method called"); }); test("#6137: dialog('open') causes form elements to reset on IE7", function() { @@ -195,23 +195,23 @@ test("#6137: dialog('open') causes form elements to reset on IE7", function() { test("#5531: dialog width should be at least minWidth on creation", function () { expect( 4 ); - var el = $("
").dialog({ + var element = $("
").dialog({ width: 200, minWidth: 300 }); - equal(el.dialog("option", "width"), 300, "width is minWidth"); - el.dialog("option", "width", 200); - equal(el.dialog("option", "width"), 300, "width unchanged when set to < minWidth"); - el.dialog("option", "width", 320); - equal(el.dialog("option", "width"), 320, "width changed if set to > minWidth"); - el.remove(); + equal(element.dialog("option", "width"), 300, "width is minWidth"); + element.dialog("option", "width", 200); + equal(element.dialog("option", "width"), 300, "width unchanged when set to < minWidth"); + element.dialog("option", "width", 320); + equal(element.dialog("option", "width"), 320, "width changed if set to > minWidth"); + element.remove(); - el = $("
").dialog({ + element = $("
").dialog({ minWidth: 300 }); - ok(el.dialog("option", "width") >= 300, "width is at least 300"); - el.remove(); + ok(element.dialog("option", "width") >= 300, "width is at least 300"); + element.remove(); }); diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index ecb7e5dd2..a295b904d 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -69,13 +69,13 @@ test( "appendTo", function() { test("autoOpen", function() { expect(2); - var el = $("
").dialog({ autoOpen: false }); - ok( !el.dialog("widget").is(":visible"), ".dialog({ autoOpen: false })"); - el.remove(); + var element = $("
").dialog({ autoOpen: false }); + ok( !element.dialog("widget").is(":visible"), ".dialog({ autoOpen: false })"); + element.remove(); - el = $("
").dialog({ autoOpen: true }); - ok( el.dialog("widget").is(":visible"), ".dialog({ autoOpen: true })"); - el.remove(); + element = $("
").dialog({ autoOpen: true }); + ok( element.dialog("widget").is(":visible"), ".dialog({ autoOpen: true })"); + element.remove(); }); test("buttons", function() { @@ -85,18 +85,18 @@ test("buttons", function() { buttons = { "Ok": function( ev ) { ok(true, "button click fires callback"); - equal(this, el[0], "context of callback"); + equal(this, element[0], "context of callback"); equal(ev.target, btn[0], "event target"); }, "Cancel": function( ev ) { ok(true, "button click fires callback"); - equal(this, el[0], "context of callback"); + equal(this, element[0], "context of callback"); equal(ev.target, btn[1], "event target"); } }, - el = $("
").dialog({ buttons: buttons }); + element = $("
").dialog({ buttons: buttons }); - btn = el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" ); + btn = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" ); equal(btn.length, 2, "number of buttons"); i = 0; @@ -106,23 +106,23 @@ test("buttons", function() { }); ok(btn.parent().hasClass("ui-dialog-buttonset"), "buttons in container"); - ok(el.parent().hasClass("ui-dialog-buttons"), "dialog wrapper adds class about having buttons"); + ok(element.parent().hasClass("ui-dialog-buttons"), "dialog wrapper adds class about having buttons"); btn.trigger("click"); newButtons = { "Close": function( ev ) { ok(true, "button click fires callback"); - equal(this, el[0], "context of callback"); + equal(this, element[0], "context of callback"); equal(ev.target, btn[0], "event target"); } }; - deepEqual(el.dialog("option", "buttons"), buttons, ".dialog('option', 'buttons') getter"); - el.dialog("option", "buttons", newButtons); - deepEqual(el.dialog("option", "buttons"), newButtons, ".dialog('option', 'buttons', ...) setter"); + deepEqual(element.dialog("option", "buttons"), buttons, ".dialog('option', 'buttons') getter"); + element.dialog("option", "buttons", newButtons); + deepEqual(element.dialog("option", "buttons"), newButtons, ".dialog('option', 'buttons', ...) setter"); - btn = el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" ); + btn = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" ); equal(btn.length, 1, "number of buttons after setter"); btn.trigger("click"); @@ -132,27 +132,27 @@ test("buttons", function() { i += 1; }); - el.dialog("option", "buttons", null); - btn = el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" ); + element.dialog("option", "buttons", null); + btn = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" ); equal(btn.length, 0, "all buttons have been removed"); - equal(el.find(".ui-dialog-buttonset").length, 0, "buttonset has been removed"); - equal(el.parent().hasClass("ui-dialog-buttons"), false, "dialog wrapper removes class about having buttons"); + equal(element.find(".ui-dialog-buttonset").length, 0, "buttonset has been removed"); + equal(element.parent().hasClass("ui-dialog-buttons"), false, "dialog wrapper removes class about having buttons"); - el.remove(); + element.remove(); }); test("buttons - advanced", function() { expect( 7 ); var buttons, - el = $("
").dialog({ + element = $("
").dialog({ buttons: [ { text: "a button", "class": "additional-class", id: "my-button-id", click: function() { - equal(this, el[0], "correct context"); + equal(this, element[0], "correct context"); }, icons: { primary: "ui-icon-cancel" @@ -162,7 +162,7 @@ test("buttons - advanced", function() { ] }); - buttons = el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" ); + buttons = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" ); equal(buttons.length, 1, "correct number of buttons"); equal(buttons.attr("id"), "my-button-id", "correct id"); equal(buttons.text(), "a button", "correct label"); @@ -171,106 +171,106 @@ test("buttons - advanced", function() { equal( buttons.button( "option", "text" ), false ); buttons.click(); - el.remove(); + element.remove(); }); test("closeOnEscape", function() { expect( 6 ); - var el = $("
").dialog({ closeOnEscape: false }); + var element = $("
").dialog({ closeOnEscape: false }); ok(true, "closeOnEscape: false"); - ok(el.dialog("widget").is(":visible") && !el.dialog("widget").is(":hidden"), "dialog is open before ESC"); - el.simulate("keydown", { keyCode: $.ui.keyCode.ESCAPE }) + ok(element.dialog("widget").is(":visible") && !element.dialog("widget").is(":hidden"), "dialog is open before ESC"); + element.simulate("keydown", { keyCode: $.ui.keyCode.ESCAPE }) .simulate("keypress", { keyCode: $.ui.keyCode.ESCAPE }) .simulate("keyup", { keyCode: $.ui.keyCode.ESCAPE }); - ok(el.dialog("widget").is(":visible") && !el.dialog("widget").is(":hidden"), "dialog is open after ESC"); + ok(element.dialog("widget").is(":visible") && !element.dialog("widget").is(":hidden"), "dialog is open after ESC"); - el.remove(); + element.remove(); - el = $("
").dialog({ closeOnEscape: true }); + element = $("
").dialog({ closeOnEscape: true }); ok(true, "closeOnEscape: true"); - ok(el.dialog("widget").is(":visible") && !el.dialog("widget").is(":hidden"), "dialog is open before ESC"); - el.simulate("keydown", { keyCode: $.ui.keyCode.ESCAPE }) + ok(element.dialog("widget").is(":visible") && !element.dialog("widget").is(":hidden"), "dialog is open before ESC"); + element.simulate("keydown", { keyCode: $.ui.keyCode.ESCAPE }) .simulate("keypress", { keyCode: $.ui.keyCode.ESCAPE }) .simulate("keyup", { keyCode: $.ui.keyCode.ESCAPE }); - ok(el.dialog("widget").is(":hidden") && !el.dialog("widget").is(":visible"), "dialog is closed after ESC"); + ok(element.dialog("widget").is(":hidden") && !element.dialog("widget").is(":visible"), "dialog is closed after ESC"); }); test("closeText", function() { expect(3); - var el = $("
").dialog(); - equal(el.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "close", + var element = $("
").dialog(); + equal(element.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "close", "default close text"); - el.remove(); + element.remove(); - el = $("
").dialog({ closeText: "foo" }); - equal(el.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "foo", + element = $("
").dialog({ closeText: "foo" }); + equal(element.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "foo", "closeText on init"); - el.remove(); + element.remove(); - el = $("
").dialog().dialog("option", "closeText", "bar"); - equal(el.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "bar", + element = $("
").dialog().dialog("option", "closeText", "bar"); + equal(element.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "bar", "closeText via option method"); - el.remove(); + element.remove(); }); test("dialogClass", function() { expect( 6 ); - var el = $("
").dialog(); - equal(el.dialog("widget").is(".foo"), false, "dialogClass not specified. foo class added"); - el.remove(); - - el = $("
").dialog({ dialogClass: "foo" }); - equal(el.dialog("widget").is(".foo"), true, "dialogClass in init. foo class added"); - el.dialog( "option", "dialogClass", "foobar" ); - equal( el.dialog("widget").is(".foo"), false, "dialogClass changed, previous one was removed" ); - equal( el.dialog("widget").is(".foobar"), true, "dialogClass changed, new one was added" ); - el.remove(); - - el = $("
").dialog({ dialogClass: "foo bar" }); - equal(el.dialog("widget").is(".foo"), true, "dialogClass in init, two classes. foo class added"); - equal(el.dialog("widget").is(".bar"), true, "dialogClass in init, two classes. bar class added"); - el.remove(); + var element = $("
").dialog(); + equal(element.dialog("widget").is(".foo"), false, "dialogClass not specified. foo class added"); + element.remove(); + + element = $("
").dialog({ dialogClass: "foo" }); + equal(element.dialog("widget").is(".foo"), true, "dialogClass in init. foo class added"); + element.dialog( "option", "dialogClass", "foobar" ); + equal( element.dialog("widget").is(".foo"), false, "dialogClass changed, previous one was removed" ); + equal( element.dialog("widget").is(".foobar"), true, "dialogClass changed, new one was added" ); + element.remove(); + + element = $("
").dialog({ dialogClass: "foo bar" }); + equal(element.dialog("widget").is(".foo"), true, "dialogClass in init, two classes. foo class added"); + equal(element.dialog("widget").is(".bar"), true, "dialogClass in init, two classes. bar class added"); + element.remove(); }); test("draggable", function() { expect(4); - var el = $("
").dialog({ draggable: false }); + var element = $("
").dialog({ draggable: false }); - TestHelpers.dialog.testDrag(el, 50, -50, 0, 0); - el.dialog("option", "draggable", true); - TestHelpers.dialog.testDrag(el, 50, -50, 50, -50); - el.remove(); + TestHelpers.dialog.testDrag(element, 50, -50, 0, 0); + element.dialog("option", "draggable", true); + TestHelpers.dialog.testDrag(element, 50, -50, 50, -50); + element.remove(); - el = $("
").dialog({ draggable: true }); - TestHelpers.dialog.testDrag(el, 50, -50, 50, -50); - el.dialog("option", "draggable", false); - TestHelpers.dialog.testDrag(el, 50, -50, 0, 0); - el.remove(); + element = $("
").dialog({ draggable: true }); + TestHelpers.dialog.testDrag(element, 50, -50, 50, -50); + element.dialog("option", "draggable", false); + TestHelpers.dialog.testDrag(element, 50, -50, 0, 0); + element.remove(); }); test("height", function() { expect(4); - var el = $("
").dialog(); - equal(el.dialog("widget").outerHeight(), 150, "default height"); - el.remove(); + var element = $("
").dialog(); + equal(element.dialog("widget").outerHeight(), 150, "default height"); + element.remove(); - el = $("
").dialog({ height: 237 }); - equal(el.dialog("widget").outerHeight(), 237, "explicit height"); - el.remove(); + element = $("
").dialog({ height: 237 }); + equal(element.dialog("widget").outerHeight(), 237, "explicit height"); + element.remove(); - el = $("
").dialog(); - el.dialog("option", "height", 238); - equal(el.dialog("widget").outerHeight(), 238, "explicit height set after init"); - el.remove(); + element = $("
").dialog(); + element.dialog("option", "height", 238); + equal(element.dialog("widget").outerHeight(), 238, "explicit height set after init"); + element.remove(); - el = $("
").css("padding", "20px") + element = $("
").css("padding", "20px") .dialog({ height: 240 }); - equal(el.dialog("widget").outerHeight(), 240, "explicit height with padding"); - el.remove(); + equal(element.dialog("widget").outerHeight(), 240, "explicit height with padding"); + element.remove(); }); asyncTest( "hide, #5860 - don't leave effects wrapper behind", function() { @@ -285,77 +285,77 @@ asyncTest( "hide, #5860 - don't leave effects wrapper behind", function() { test("maxHeight", function() { expect(3); - var el = $("
").dialog({ maxHeight: 200 }); - TestHelpers.dialog.drag(el, ".ui-resizable-s", 1000, 1000); - closeEnough(el.dialog("widget").height(), 200, 1, "maxHeight"); - el.remove(); + var element = $("
").dialog({ maxHeight: 200 }); + TestHelpers.dialog.drag(element, ".ui-resizable-s", 1000, 1000); + closeEnough(element.dialog("widget").height(), 200, 1, "maxHeight"); + element.remove(); - el = $("
").dialog({ maxHeight: 200 }); - TestHelpers.dialog.drag(el, ".ui-resizable-n", -1000, -1000); - closeEnough(el.dialog("widget").height(), 200, 1, "maxHeight"); - el.remove(); + element = $("
").dialog({ maxHeight: 200 }); + TestHelpers.dialog.drag(element, ".ui-resizable-n", -1000, -1000); + closeEnough(element.dialog("widget").height(), 200, 1, "maxHeight"); + element.remove(); - el = $("
").dialog({ maxHeight: 200 }).dialog("option", "maxHeight", 300); - TestHelpers.dialog.drag(el, ".ui-resizable-s", 1000, 1000); - closeEnough(el.dialog("widget").height(), 300, 1, "maxHeight"); - el.remove(); + element = $("
").dialog({ maxHeight: 200 }).dialog("option", "maxHeight", 300); + TestHelpers.dialog.drag(element, ".ui-resizable-s", 1000, 1000); + closeEnough(element.dialog("widget").height(), 300, 1, "maxHeight"); + element.remove(); }); test("maxWidth", function() { expect(3); - var el = $("
").dialog({ maxWidth: 200 }); - TestHelpers.dialog.drag(el, ".ui-resizable-e", 1000, 1000); - closeEnough(el.dialog("widget").width(), 200, 1, "maxWidth"); - el.remove(); + var element = $("
").dialog({ maxWidth: 200 }); + TestHelpers.dialog.drag(element, ".ui-resizable-e", 1000, 1000); + closeEnough(element.dialog("widget").width(), 200, 1, "maxWidth"); + element.remove(); - el = $("
").dialog({ maxWidth: 200 }); - TestHelpers.dialog.drag(el, ".ui-resizable-w", -1000, -1000); - closeEnough(el.dialog("widget").width(), 200, 1, "maxWidth"); - el.remove(); + element = $("
").dialog({ maxWidth: 200 }); + TestHelpers.dialog.drag(element, ".ui-resizable-w", -1000, -1000); + closeEnough(element.dialog("widget").width(), 200, 1, "maxWidth"); + element.remove(); - el = $("
").dialog({ maxWidth: 200 }).dialog("option", "maxWidth", 300); - TestHelpers.dialog.drag(el, ".ui-resizable-w", -1000, -1000); - closeEnough(el.dialog("widget").width(), 300, 1, "maxWidth"); - el.remove(); + element = $("
").dialog({ maxWidth: 200 }).dialog("option", "maxWidth", 300); + TestHelpers.dialog.drag(element, ".ui-resizable-w", -1000, -1000); + closeEnough(element.dialog("widget").width(), 300, 1, "maxWidth"); + element.remove(); }); test("minHeight", function() { expect(3); - var el = $("
").dialog({ minHeight: 10 }); - TestHelpers.dialog.drag(el, ".ui-resizable-s", -1000, -1000); - closeEnough(el.dialog("widget").height(), 10, 1, "minHeight"); - el.remove(); + var element = $("
").dialog({ minHeight: 10 }); + TestHelpers.dialog.drag(element, ".ui-resizable-s", -1000, -1000); + closeEnough(element.dialog("widget").height(), 10, 1, "minHeight"); + element.remove(); - el = $("
").dialog({ minHeight: 10 }); - TestHelpers.dialog.drag(el, ".ui-resizable-n", 1000, 1000); - closeEnough(el.dialog("widget").height(), 10, 1, "minHeight"); - el.remove(); + element = $("
").dialog({ minHeight: 10 }); + TestHelpers.dialog.drag(element, ".ui-resizable-n", 1000, 1000); + closeEnough(element.dialog("widget").height(), 10, 1, "minHeight"); + element.remove(); - el = $("
").dialog({ minHeight: 10 }).dialog("option", "minHeight", 30); - TestHelpers.dialog.drag(el, ".ui-resizable-n", 1000, 1000); - closeEnough(el.dialog("widget").height(), 30, 1, "minHeight"); - el.remove(); + element = $("
").dialog({ minHeight: 10 }).dialog("option", "minHeight", 30); + TestHelpers.dialog.drag(element, ".ui-resizable-n", 1000, 1000); + closeEnough(element.dialog("widget").height(), 30, 1, "minHeight"); + element.remove(); }); test("minWidth", function() { expect(3); - var el = $("
").dialog({ minWidth: 10 }); - TestHelpers.dialog.drag(el, ".ui-resizable-e", -1000, -1000); - closeEnough(el.dialog("widget").width(), 10, 1, "minWidth"); - el.remove(); + var element = $("
").dialog({ minWidth: 10 }); + TestHelpers.dialog.drag(element, ".ui-resizable-e", -1000, -1000); + closeEnough(element.dialog("widget").width(), 10, 1, "minWidth"); + element.remove(); - el = $("
").dialog({ minWidth: 10 }); - TestHelpers.dialog.drag(el, ".ui-resizable-w", 1000, 1000); - closeEnough(el.dialog("widget").width(), 10, 1, "minWidth"); - el.remove(); + element = $("
").dialog({ minWidth: 10 }); + TestHelpers.dialog.drag(element, ".ui-resizable-w", 1000, 1000); + closeEnough(element.dialog("widget").width(), 10, 1, "minWidth"); + element.remove(); - el = $("
").dialog({ minWidth: 30 }).dialog("option", "minWidth", 30); - TestHelpers.dialog.drag(el, ".ui-resizable-w", 1000, 1000); - closeEnough(el.dialog("widget").width(), 30, 1, "minWidth"); - el.remove(); + element = $("
").dialog({ minWidth: 30 }).dialog("option", "minWidth", 30); + TestHelpers.dialog.drag(element, ".ui-resizable-w", 1000, 1000); + closeEnough(element.dialog("widget").width(), 30, 1, "minWidth"); + element.remove(); }); test( "position, default center on window", function() { @@ -366,12 +366,12 @@ test( "position, default center on window", function() { // Support: FF, IE7 var winWidth = $( window ).width(), winHeight = $( window ).height(), - el = $("
").dialog(), - dialog = el.dialog("widget"), + element = $("
").dialog(), + dialog = element.dialog("widget"), offset = dialog.offset(); closeEnough( offset.left, Math.round( winWidth / 2 - dialog.outerWidth() / 2 ) + $( window ).scrollLeft(), 1, "dialog left position of center on window on initilization" ); closeEnough( offset.top, Math.round( winHeight / 2 - dialog.outerHeight() / 2 ) + $( window ).scrollTop(), 1, "dialog top position of center on window on initilization" ); - el.remove(); + element.remove(); }); test( "position, right bottom at right bottom via ui.position args", function() { @@ -382,18 +382,18 @@ test( "position, right bottom at right bottom via ui.position args", function() // Support: FF, IE7 var winWidth = $( window ).width(), winHeight = $( window ).height(), - el = $("
").dialog({ + element = $("
").dialog({ position: { my: "right bottom", at: "right bottom" } }), - dialog = el.dialog("widget"), + dialog = element.dialog("widget"), offset = dialog.offset(); closeEnough( offset.left, winWidth - dialog.outerWidth() + $( window ).scrollLeft(), 1, "dialog left position of right bottom at right bottom on initilization" ); closeEnough( offset.top, winHeight - dialog.outerHeight() + $( window ).scrollTop(), 1, "dialog top position of right bottom at right bottom on initilization" ); - el.remove(); + element.remove(); }); test( "position, at another element", function() { @@ -406,7 +406,7 @@ test( "position, at another element", function() { width: 10 }).appendTo("body"), - el = $("
").dialog({ + element = $("
").dialog({ position: { my: "left top", at: "left top", @@ -415,13 +415,13 @@ test( "position, at another element", function() { } }), - dialog = el.dialog("widget"), + dialog = element.dialog("widget"), offset = dialog.offset(); closeEnough( offset.left, 600, 1, "dialog left position at another element on initilization" ); closeEnough( offset.top, 400, 1, "dialog top position at another element on initilization" ); - el.dialog("option", "position", { + element.dialog("option", "position", { my: "left top", at: "right bottom", of: parent, @@ -433,111 +433,111 @@ test( "position, at another element", function() { closeEnough( offset.left, 610, 1, "dialog left position at another element via setting option" ); closeEnough( offset.top, 410, 1, "dialog top position at another element via setting option" ); - el.remove(); + element.remove(); parent.remove(); }); test("resizable", function() { expect(4); - var el = $("
").dialog(); - TestHelpers.dialog.shouldResize(el, 50, 50, "[default]"); - el.dialog("option", "resizable", false); - TestHelpers.dialog.shouldResize(el, 0, 0, "disabled after init"); - el.remove(); - - el = $("
").dialog({ resizable: false }); - TestHelpers.dialog.shouldResize(el, 0, 0, "disabled in init options"); - el.dialog("option", "resizable", true); - TestHelpers.dialog.shouldResize(el, 50, 50, "enabled after init"); - el.remove(); + var element = $("
").dialog(); + TestHelpers.dialog.shouldResize(element, 50, 50, "[default]"); + element.dialog("option", "resizable", false); + TestHelpers.dialog.shouldResize(element, 0, 0, "disabled after init"); + element.remove(); + + element = $("
").dialog({ resizable: false }); + TestHelpers.dialog.shouldResize(element, 0, 0, "disabled in init options"); + element.dialog("option", "resizable", true); + TestHelpers.dialog.shouldResize(element, 50, 50, "enabled after init"); + element.remove(); }); test( "title", function() { expect( 11 ); function titleText() { - return el.dialog("widget").find( ".ui-dialog-title" ).html(); + return element.dialog("widget").find( ".ui-dialog-title" ).html(); } - var el = $( "
" ).dialog(); + var element = $( "
" ).dialog(); // some browsers return a non-breaking space and some return " " // so we generate a non-breaking space for comparison equal( titleText(), $( " " ).html(), "[default]" ); - equal( el.dialog( "option", "title" ), null, "option not changed" ); - el.remove(); + equal( element.dialog( "option", "title" ), null, "option not changed" ); + element.remove(); - el = $( "
" ).dialog(); + element = $( "
" ).dialog(); equal( titleText(), "foo", "title in element attribute" ); - equal( el.dialog( "option", "title"), "foo", "option updated from attribute" ); - el.remove(); + equal( element.dialog( "option", "title"), "foo", "option updated from attribute" ); + element.remove(); - el = $( "
" ).dialog({ title: "foo" }); + element = $( "
" ).dialog({ title: "foo" }); equal( titleText(), "foo", "title in init options" ); - equal( el.dialog("option", "title"), "foo", "opiton set from options hash" ); - el.remove(); + equal( element.dialog("option", "title"), "foo", "opiton set from options hash" ); + element.remove(); - el = $( "
" ).dialog({ title: "bar" }); + element = $( "
" ).dialog({ title: "bar" }); equal( titleText(), "bar", "title in init options should override title in element attribute" ); - equal( el.dialog("option", "title"), "bar", "opiton set from options hash" ); - el.remove(); + equal( element.dialog("option", "title"), "bar", "opiton set from options hash" ); + element.remove(); - el = $( "
" ).dialog().dialog( "option", "title", "foo" ); + element = $( "
" ).dialog().dialog( "option", "title", "foo" ); equal( titleText(), "foo", "title after init" ); - el.remove(); + element.remove(); // make sure attroperties are properly ignored - #5742 - .attr() might return a DOMElement - el = $( "
" ).dialog(); + element = $( "
" ).dialog(); // some browsers return a non-breaking space and some return " " // so we get the text to normalize to the actual non-breaking space equal( titleText(), $( " " ).html(), "[default]" ); - equal( el.dialog( "option", "title" ), null, "option not changed" ); - el.remove(); + equal( element.dialog( "option", "title" ), null, "option not changed" ); + element.remove(); }); test("width", function() { expect(3); - var el = $("
").dialog(); - closeEnough(el.dialog("widget").width(), 300, 1, "default width"); - el.remove(); + var element = $("
").dialog(); + closeEnough(element.dialog("widget").width(), 300, 1, "default width"); + element.remove(); - el = $("
").dialog({width: 437 }); - closeEnough(el.dialog("widget").width(), 437, 1, "explicit width"); - el.dialog("option", "width", 438); - closeEnough(el.dialog("widget").width(), 438, 1, "explicit width after init"); - el.remove(); + element = $("
").dialog({width: 437 }); + closeEnough(element.dialog("widget").width(), 437, 1, "explicit width"); + element.dialog("option", "width", 438); + closeEnough(element.dialog("widget").width(), 438, 1, "explicit width after init"); + element.remove(); }); test("#4826: setting resizable false toggles resizable on dialog", function() { expect(6); var i, - el = $("
").dialog({ resizable: false }); + element = $("
").dialog({ resizable: false }); - TestHelpers.dialog.shouldResize(el, 0, 0, "[default]"); + TestHelpers.dialog.shouldResize(element, 0, 0, "[default]"); for (i=0; i<2; i++) { - el.dialog("close").dialog("open"); - TestHelpers.dialog.shouldResize(el, 0, 0, "initialized with resizable false toggle ("+ (i+1) +")"); + element.dialog("close").dialog("open"); + TestHelpers.dialog.shouldResize(element, 0, 0, "initialized with resizable false toggle ("+ (i+1) +")"); } - el.remove(); + element.remove(); - el = $("
").dialog({ resizable: true }); - TestHelpers.dialog.shouldResize(el, 50, 50, "[default]"); + element = $("
").dialog({ resizable: true }); + TestHelpers.dialog.shouldResize(element, 50, 50, "[default]"); for (i=0; i<2; i++) { - el.dialog("close").dialog("option", "resizable", false).dialog("open"); - TestHelpers.dialog.shouldResize(el, 0, 0, "set option resizable false toggle ("+ (i+1) +")"); + element.dialog("close").dialog("option", "resizable", false).dialog("open"); + TestHelpers.dialog.shouldResize(element, 0, 0, "set option resizable false toggle ("+ (i+1) +")"); } - el.remove(); + element.remove(); }); asyncTest( "#8051 - 'Explode' dialog animation causes crash in IE 6, 7 and 8", function() { expect( 1 ); - var el = $( "
" ).dialog({ + var element = $( "
" ).dialog({ show: "explode", focus: function() { ok( true, "dialog opened with animation" ); - el.remove(); + element.remove(); start(); } }); @@ -545,11 +545,11 @@ asyncTest( "#8051 - 'Explode' dialog animation causes crash in IE 6, 7 and 8", f asyncTest( "#4421 - Focus lost from dialog which uses show-effect", function() { expect( 1 ); - var el = $( "
" ).dialog({ + var element = $( "
" ).dialog({ show: "blind", focus: function() { - equal( el.dialog( "widget" ).find( ":focus" ).length, 1, "dialog maintains focus" ); - el.remove(); + equal( element.dialog( "widget" ).find( ":focus" ).length, 1, "dialog maintains focus" ); + element.remove(); start(); } }); @@ -557,17 +557,17 @@ asyncTest( "#4421 - Focus lost from dialog which uses show-effect", function() { asyncTest( "Open followed by close during show effect", function() { expect( 1 ); - var el = $( "
" ).dialog({ + var element = $( "
" ).dialog({ show: "blind", close: function() { ok( true, "dialog closed properly during animation" ); - el.remove(); + element.remove(); start(); } }); setTimeout( function() { - el.dialog("close"); + element.dialog("close"); }, 100 ); }); diff --git a/tests/unit/dialog/dialog_test_helpers.js b/tests/unit/dialog/dialog_test_helpers.js index 4ecaf0c0f..64e8dbf6f 100644 --- a/tests/unit/dialog/dialog_test_helpers.js +++ b/tests/unit/dialog/dialog_test_helpers.js @@ -1,6 +1,6 @@ TestHelpers.dialog = { - drag: function(el, handle, dx, dy) { - var d = el.dialog("widget"); + drag: function(element, handle, dx, dy) { + var d = element.dialog("widget"); //this mouseover is to work around a limitation in resizable //TODO: fix resizable so handle doesn't require mouseover in order to be used $( handle, d ).simulate("mouseover").simulate( "drag", { @@ -8,13 +8,13 @@ TestHelpers.dialog = { dy: dy }); }, - testDrag: function(el, dx, dy, expectedDX, expectedDY, msg) { + testDrag: function(element, dx, dy, expectedDX, expectedDY, msg) { var actualDX, actualDY, offsetAfter, - d = el.dialog("widget"), + d = element.dialog("widget"), handle = $(".ui-dialog-titlebar", d), offsetBefore = d.offset(); - TestHelpers.dialog.drag(el, handle, dx, dy); + TestHelpers.dialog.drag(element, handle, dx, dy); offsetAfter = d.offset(); @@ -24,14 +24,14 @@ TestHelpers.dialog = { actualDY = offsetAfter.top - offsetBefore.top; ok( expectedDX - actualDX <= 1 && expectedDY - actualDY <= 1, "dragged[" + expectedDX + ", " + expectedDY + "] " + msg); }, - shouldResize: function(el, dw, dh, msg) { + shouldResize: function(element, dw, dh, msg) { var heightAfter, widthAfter, actual, expected, - d = el.dialog("widget"), + d = element.dialog("widget"), handle = $(".ui-resizable-se", d), heightBefore = d.height(), widthBefore = d.width(); - TestHelpers.dialog.drag(el, handle, 50, 50); + TestHelpers.dialog.drag(element, handle, 50, 50); heightAfter = d.height(); widthAfter = d.width(); @@ -41,4 +41,4 @@ TestHelpers.dialog = { expected = { width: widthBefore + dw, height: heightBefore + dh }; deepEqual(actual, expected, "resized[" + 50 + ", " + 50 + "] " + msg); } -}; \ No newline at end of file +}; -- 2.39.5