diff options
Diffstat (limited to 'tests/unit/dialog/dialog_options.js')
-rw-r--r-- | tests/unit/dialog/dialog_options.js | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index b5eda1fcf..cda16aadc 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -242,8 +242,8 @@ test("modal", function() { test("position, default center on window", function() { var el = $('<div></div>').dialog(); - var offset = el.parent().offset(); - // use .position() instead to avoid replicating center-logic? + var dialog = el.dialog('widget'); + var offset = dialog.offset(); same(offset.left, Math.floor($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft()); same(offset.top, Math.floor($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop()); el.remove(); @@ -251,16 +251,16 @@ test("position, default center on window", function() { test("position, top on window", function() { var el = $('<div></div>').dialog({ position: "top" }); - var dialog = el.closest('.ui-dialog'); + var dialog = el.dialog('widget'); var offset = dialog.offset(); - same(offset.left, Math.floor($(window).width() / 2 - dialog.outerWidth() / 2)); + same(offset.left, Math.floor($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft()); same(offset.top, $(window).scrollTop()); el.remove(); }); test("position, left on window", function() { var el = $('<div></div>').dialog({ position: "left" }); - var dialog = el.closest('.ui-dialog'); + var dialog = el.dialog('widget'); var offset = dialog.offset(); same(offset.left, 0); same(offset.top, Math.floor($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop()); @@ -269,27 +269,27 @@ test("position, left on window", function() { test("position, right bottom on window", function() { var el = $('<div></div>').dialog({ position: "right bottom" }); - var dialog = el.closest('.ui-dialog'); + var dialog = el.dialog('widget'); var offset = dialog.offset(); - same(offset.left, $(window).width() - dialog.outerWidth()); + same(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft()); same(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.closest('.ui-dialog'); + var dialog = el.dialog('widget'); var offset = dialog.offset(); - same(offset.left, $(window).width() - dialog.outerWidth()); + same(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft()); same(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.closest('.ui-dialog'); + var dialog = el.dialog('widget'); var offset = dialog.offset(); - same(offset.left, 10); + same(offset.left, 10 + $(window).scrollLeft()); same(offset.top, 10 + $(window).scrollTop()); el.remove(); }); @@ -302,10 +302,10 @@ test("position, right bottom at right bottom via ui.position args", function() { } }); - var dialog = el.closest('.ui-dialog'); + var dialog = el.dialog('widget'); var offset = dialog.offset(); - same(offset.left, $(window).width() - dialog.outerWidth()); + same(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft()); same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop()); el.remove(); }); @@ -317,22 +317,21 @@ test("position, at another element", function() { left: 600, height: 10, width: 10 - }); + }).appendTo('body'); var el = $('<div></div>').dialog({ position: { my: "left top", - at: "top left", + at: "left top", of: parent } }); - var dialog = el.closest('.ui-dialog'); + var dialog = el.dialog('widget'); var offset = dialog.offset(); - var parentOffset = parent.offset(); - same(offset.left, parentOffset.left); - same(offset.top, parentOffset.top); + same(offset.left, 600); + same(offset.top, 400); el.dialog('option', 'position', { my: "left top", @@ -340,18 +339,15 @@ test("position, at another element", function() { of: parent }); - same(offset.left, parentOffset.left + parent.outerWidth()); - same(offset.top, parentOffset.top + parent.outerHeight()); + var offset = dialog.offset(); + + same(offset.left, 610); + same(offset.top, 410); el.remove(); parent.remove(); }); - -test("position, others", function() { - ok(false, 'missing test - untested code is broken code'); -}); - test("resizable", function() { expect(4); |