diff options
author | Scott González <scott.gonzalez@gmail.com> | 2012-04-19 10:27:06 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2012-04-19 10:28:26 -0400 |
commit | 0a5a9090f827cd186ac486344327bcbb3901fd34 (patch) | |
tree | 085dfcb5a99db48b464bff91e112a37cf6e206af /tests/unit/dialog | |
parent | 58a120bb4b022b3d2237aabaa960e42d9fe821ba (diff) | |
download | jquery-ui-0a5a9090f827cd186ac486344327bcbb3901fd34.tar.gz jquery-ui-0a5a9090f827cd186ac486344327bcbb3901fd34.zip |
Tests: Lint.
Diffstat (limited to 'tests/unit/dialog')
-rw-r--r-- | tests/unit/dialog/dialog_core.js | 8 | ||||
-rw-r--r-- | tests/unit/dialog/dialog_events.js | 10 | ||||
-rw-r--r-- | tests/unit/dialog/dialog_methods.js | 9 | ||||
-rw-r--r-- | tests/unit/dialog/dialog_options.js | 94 | ||||
-rw-r--r-- | tests/unit/dialog/dialog_tickets.js | 21 |
5 files changed, 74 insertions, 68 deletions
diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js index 4a671968e..5d7beb99b 100644 --- a/tests/unit/dialog/dialog_core.js +++ b/tests/unit/dialog/dialog_core.js @@ -40,8 +40,8 @@ function drag(handle, dx, dy) { function moved(dx, dy, msg) { msg = msg ? msg + "." : ""; - var actual = { left: Math.round(offsetAfter.left), top: Math.round(offsetAfter.top) }; - var expected = { left: Math.round(offsetBefore.left + dx), top: Math.round(offsetBefore.top + dy) }; + var actual = { left: Math.round(offsetAfter.left), top: Math.round(offsetAfter.top) }, + expected = { left: Math.round(offsetBefore.left + dx), top: Math.round(offsetBefore.top + dy) }; deepEqual(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg); } @@ -59,8 +59,8 @@ function shouldnotmove(why) { function resized(dw, dh, msg) { msg = msg ? msg + "." : ""; - var actual = { width: widthAfter, height: heightAfter }; - var expected = { width: widthBefore + dw, height: heightBefore + dh }; + var actual = { width: widthAfter, height: heightAfter }, + expected = { width: widthBefore + dw, height: heightBefore + dh }; deepEqual(actual, expected, 'resized[' + dragged.dx + ', ' + dragged.dy + '] ' + msg); } diff --git a/tests/unit/dialog/dialog_events.js b/tests/unit/dialog/dialog_events.js index 4b769bafc..85afa5a3b 100644 --- a/tests/unit/dialog/dialog_events.js +++ b/tests/unit/dialog/dialog_events.js @@ -63,7 +63,8 @@ test("dragStart", function() { test("drag", function() { expect(9); - var hasDragged = false; + var handle, + hasDragged = false; el = $('<div></div>').dialog({ drag: function(ev, ui) { @@ -83,7 +84,7 @@ test("drag", function() { ok(ui.position !== undefined, "ui.position in callback"); ok(ui.offset !== undefined, "ui.offset in callback"); }); - var handle = $(".ui-dialog-titlebar", dlg()); + handle = $(".ui-dialog-titlebar", dlg()); drag(handle, 50, 50); el.remove(); }); @@ -138,7 +139,8 @@ test("resizeStart", function() { test("resize", function() { expect(13); - var hasResized = false; + var handle, + hasResized = false; el = $('<div></div>').dialog({ resize: function(ev, ui) { @@ -162,7 +164,7 @@ test("resize", function() { ok(ui.position !== undefined, "ui.position in callback"); ok(ui.size !== undefined, "ui.size in callback"); }); - var handle = $(".ui-resizable-se", dlg()); + handle = $(".ui-resizable-se", dlg()); drag(handle, 50, 50); el.remove(); }); diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index 645baa9f5..1f84cd6b5 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -98,14 +98,17 @@ test("isOpen", function() { }); test("moveToTop", function() { - var expected = $('<div></div>').dialog(), + var d1, d2, dlg1, dlg2, + expected = $('<div></div>').dialog(), actual = expected.dialog('moveToTop'); equal(actual, expected, 'moveToTop is chainable'); - var d1 = $('<div></div>').dialog(), dlg1 = d1.parents('.ui-dialog'); + d1 = $('<div></div>').dialog(); + dlg1 = d1.parents('.ui-dialog'); d1.dialog('close'); d1.dialog('open'); - var d2 = $('<div></div>').dialog(), dlg2 = d2.parents('.ui-dialog'); + d2 = $('<div></div>').dialog(); + dlg2 = d2.parents('.ui-dialog'); d2.dialog('close'); d2.dialog('open'); ok(dlg1.css('zIndex') < dlg2.css('zIndex'), 'dialog 1 under dialog 2 before moveToTop method called'); diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index 10443892b..c071c1b09 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -20,7 +20,8 @@ test("autoOpen", function() { test("buttons", function() { expect(21); - var buttons = { + var btn, i, newButtons, + buttons = { "Ok": function(ev, ui) { ok(true, "button click fires callback"); equal(this, el[0], "context of callback"); @@ -34,10 +35,10 @@ test("buttons", function() { }; el = $('<div></div>').dialog({ buttons: buttons }); - var btn = $("button", dlg()); + btn = $("button", dlg()); equal(btn.length, 2, "number of buttons"); - var i = 0; + i = 0; $.each(buttons, function(key, val) { equal(btn.eq(i).text(), key, "text of button " + (i+1)); i++; @@ -48,7 +49,7 @@ test("buttons", function() { btn.trigger("click"); - var newButtons = { + newButtons = { "Close": function(ev, ui) { ok(true, "button click fires callback"); equal(this, el[0], "context of callback"); @@ -275,54 +276,54 @@ test("minWidth", function() { }); test("position, default center on window", function() { - var el = $('<div></div>').dialog(); - var dialog = el.dialog('widget'); - var offset = dialog.offset(); + var el = $('<div></div>').dialog(), + dialog = el.dialog('widget'), + offset = dialog.offset(); deepEqual(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft()); deepEqual(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop()); el.remove(); }); test("position, top on window", function() { - var el = $('<div></div>').dialog({ position: "top" }); - var dialog = el.dialog('widget'); - var offset = dialog.offset(); + var el = $('<div></div>').dialog({ position: "top" }), + dialog = el.dialog('widget'), + offset = dialog.offset(); deepEqual(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft()); deepEqual(offset.top, $(window).scrollTop()); el.remove(); }); test("position, left on window", function() { - var el = $('<div></div>').dialog({ position: "left" }); - var dialog = el.dialog('widget'); - var offset = dialog.offset(); + var el = $('<div></div>').dialog({ position: "left" }), + dialog = el.dialog('widget'), + offset = dialog.offset(); deepEqual(offset.left, 0); deepEqual(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop()); el.remove(); }); test("position, right bottom on window", function() { - var el = $('<div></div>').dialog({ position: "right bottom" }); - var dialog = el.dialog('widget'); - var offset = dialog.offset(); + var el = $('<div></div>').dialog({ position: "right bottom" }), + dialog = el.dialog('widget'), + offset = dialog.offset(); deepEqual(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft()); deepEqual(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop()); el.remove(); }); test("position, right bottom on window w/array", function() { - var el = $('<div></div>').dialog({ position: ["right", "bottom"] }); - var dialog = el.dialog('widget'); - var offset = dialog.offset(); + var el = $('<div></div>').dialog({ position: ["right", "bottom"] }), + dialog = el.dialog('widget'), + offset = dialog.offset(); deepEqual(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft()); deepEqual(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop()); el.remove(); }); test("position, offset from top left w/array", function() { - var el = $('<div></div>').dialog({ position: [10, 10] }); - var dialog = el.dialog('widget'); - var offset = dialog.offset(); + var el = $('<div></div>').dialog({ position: [10, 10] }), + dialog = el.dialog('widget'), + offset = dialog.offset(); deepEqual(offset.left, 10 + $(window).scrollLeft()); deepEqual(offset.top, 10 + $(window).scrollTop()); el.remove(); @@ -330,14 +331,13 @@ test("position, offset from top left w/array", function() { test("position, right bottom at right bottom via ui.position args", function() { var el = $('<div></div>').dialog({ - position: { - my: "right bottom", - at: "right bottom" - } - }); - - var dialog = el.dialog('widget'); - var offset = dialog.offset(); + position: { + my: "right bottom", + at: "right bottom" + } + }), + dialog = el.dialog('widget'), + offset = dialog.offset(); deepEqual(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft()); deepEqual(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop()); @@ -346,23 +346,23 @@ test("position, right bottom at right bottom via ui.position args", function() { test("position, at another element", function() { var parent = $('<div></div>').css({ - position: 'absolute', - top: 400, - left: 600, - height: 10, - width: 10 - }).appendTo('body'); - - var el = $('<div></div>').dialog({ - position: { - my: "left top", - at: "left top", - of: parent - } - }); + position: 'absolute', + top: 400, + left: 600, + height: 10, + width: 10 + }).appendTo('body'), + + el = $('<div></div>').dialog({ + position: { + my: "left top", + at: "left top", + of: parent + } + }), - var dialog = el.dialog('widget'); - var offset = dialog.offset(); + dialog = el.dialog('widget'), + offset = dialog.offset(); deepEqual(offset.left, 600); deepEqual(offset.top, 400); @@ -373,7 +373,7 @@ test("position, at another element", function() { of: parent }); - var offset = dialog.offset(); + offset = dialog.offset(); deepEqual(offset.left, 610); deepEqual(offset.top, 410); diff --git a/tests/unit/dialog/dialog_tickets.js b/tests/unit/dialog/dialog_tickets.js index bd9056153..a169bd1a5 100644 --- a/tests/unit/dialog/dialog_tickets.js +++ b/tests/unit/dialog/dialog_tickets.js @@ -12,12 +12,6 @@ asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() { inputs = el.find( "input" ), widget = el.dialog( "widget" ); - inputs.eq( 1 ).focus(); - equal( document.activeElement, inputs[1], "Focus set on second input" ); - inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB }); - - setTimeout( checkTab, 2 ); - function checkTab() { ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" ); @@ -32,14 +26,21 @@ asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() { el.remove(); start(); } + + inputs.eq( 1 ).focus(); + equal( document.activeElement, inputs[1], "Focus set on second input" ); + inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB }); + + setTimeout( checkTab, 2 ); }); test("#4826: setting resizable false toggles resizable on dialog", function() { expect(6); + var i; el = $('<div></div>').dialog({ resizable: false }); shouldnotresize("[default]"); - for (var i=0; i<2; i++) { + for (i=0; i<2; i++) { el.dialog('close').dialog('open'); shouldnotresize('initialized with resizable false toggle ('+ (i+1) +')'); } @@ -47,7 +48,7 @@ test("#4826: setting resizable false toggles resizable on dialog", function() { el = $('<div></div>').dialog({ resizable: true }); shouldresize("[default]"); - for (var i=0; i<2; i++) { + for (i=0; i<2; i++) { el.dialog('close').dialog('option', 'resizable', false).dialog('open'); shouldnotresize('set option resizable false toggle ('+ (i+1) +')'); } @@ -108,7 +109,7 @@ test("#6137: dialog('open') causes form elements to reset on IE7", function() { test("#6645: Missing element not found check in overlay", function(){ expect(2); d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true}); - d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove()}}); + d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove(); }}); equal($.ui.dialog.overlay.instances.length, 2, 'two overlays created'); d2.dialog('close'); equal($.ui.dialog.overlay.instances.length, 1, 'one overlay remains after closing the 2nd overlay'); @@ -119,7 +120,7 @@ test("#6966: Escape key closes all dialogs, not the top one", function(){ expect(8); // test with close function removing dialog d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true}); - d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove()}}); + d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove(); }}); ok(d1.dialog("isOpen"), 'first dialog is open'); ok(d2.dialog("isOpen"), 'second dialog is open'); d2.simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE}); |