aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/dialog
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/dialog')
-rw-r--r--tests/unit/dialog/dialog_options.js103
1 files changed, 101 insertions, 2 deletions
diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js
index 28b3812b5..b5eda1fcf 100644
--- a/tests/unit/dialog/dialog_options.js
+++ b/tests/unit/dialog/dialog_options.js
@@ -244,11 +244,110 @@ 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?
- same(offset.left, Math.floor($(window).width() / 2 - el.parent().width() / 2));
- same(offset.top, Math.floor($(window).height() / 2 - el.parent().height() / 2));
+ 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();
});
+test("position, top on window", function() {
+ var el = $('<div></div>').dialog({ position: "top" });
+ var dialog = el.closest('.ui-dialog');
+ var offset = dialog.offset();
+ same(offset.left, Math.floor($(window).width() / 2 - dialog.outerWidth() / 2));
+ 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 offset = dialog.offset();
+ same(offset.left, 0);
+ same(offset.top, Math.floor($(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.closest('.ui-dialog');
+ var offset = dialog.offset();
+ same(offset.left, $(window).width() - dialog.outerWidth());
+ 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 offset = dialog.offset();
+ same(offset.left, $(window).width() - dialog.outerWidth());
+ 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 offset = dialog.offset();
+ same(offset.left, 10);
+ same(offset.top, 10 + $(window).scrollTop());
+ el.remove();
+});
+
+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.closest('.ui-dialog');
+ var offset = dialog.offset();
+
+ same(offset.left, $(window).width() - dialog.outerWidth());
+ same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
+ el.remove();
+});
+
+test("position, at another element", function() {
+ var parent = $('<div></div>').css({
+ position: 'absolute',
+ top: 400,
+ left: 600,
+ height: 10,
+ width: 10
+ });
+
+ var el = $('<div></div>').dialog({
+ position: {
+ my: "left top",
+ at: "top left",
+ of: parent
+ }
+ });
+
+ var dialog = el.closest('.ui-dialog');
+ var offset = dialog.offset();
+ var parentOffset = parent.offset();
+
+ same(offset.left, parentOffset.left);
+ same(offset.top, parentOffset.top);
+
+ el.dialog('option', 'position', {
+ my: "left top",
+ at: "right bottom",
+ of: parent
+ });
+
+ same(offset.left, parentOffset.left + parent.outerWidth());
+ same(offset.top, parentOffset.top + parent.outerHeight());
+
+ el.remove();
+ parent.remove();
+});
+
+
test("position, others", function() {
ok(false, 'missing test - untested code is broken code');
});