aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2015-04-06 20:23:50 -0400
committerScott González <scott.gonzalez@gmail.com>2015-04-09 09:26:27 -0400
commit7d4811206f8b64e9bd8eea168a77edf23629659b (patch)
treeb22edbe4117b692ced3f803fd5192c046229e56e /tests/unit
parent0714f55ad48c9d3dace29003677353f5e152a13a (diff)
downloadjquery-ui-7d4811206f8b64e9bd8eea168a77edf23629659b.tar.gz
jquery-ui-7d4811206f8b64e9bd8eea168a77edf23629659b.zip
Dialog: Convert tests to new infrastructure
Ref #10119 Ref gh-1528
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/dialog/dialog.html38
-rw-r--r--tests/unit/dialog/dialog_common.js9
-rw-r--r--tests/unit/dialog/dialog_common_deprecated.js9
-rw-r--r--tests/unit/dialog/dialog_core.js11
-rw-r--r--tests/unit/dialog/dialog_deprecated.html37
-rw-r--r--tests/unit/dialog/dialog_deprecated.js7
-rw-r--r--tests/unit/dialog/dialog_events.js23
-rw-r--r--tests/unit/dialog/dialog_methods.js18
-rw-r--r--tests/unit/dialog/dialog_options.js61
-rw-r--r--tests/unit/dialog/dialog_test_helpers.js12
10 files changed, 92 insertions, 133 deletions
diff --git a/tests/unit/dialog/dialog.html b/tests/unit/dialog/dialog.html
index 5434e6bfc..aa0e3d3ec 100644
--- a/tests/unit/dialog/dialog.html
+++ b/tests/unit/dialog/dialog.html
@@ -4,42 +4,8 @@
<meta charset="utf-8">
<title>jQuery UI Dialog Test Suite</title>
- <script src="../../jquery.js"></script>
- <script>
- $.uiBackCompat = false;
- </script>
- <link rel="stylesheet" href="../../../external/qunit/qunit.css">
- <script src="../../../external/qunit/qunit.js"></script>
- <script src="../../../external/jquery-simulate/jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
- <script src="../../../external/qunit-assert-classes/qunit-assert-classes.js"></script>
- <script>
- TestHelpers.loadResources({
- css: [ "core", "dialog" ],
- js: [
- "ui/core.js",
- "ui/widget.js",
- "ui/position.js",
- "ui/mouse.js",
- "ui/draggable.js",
- "ui/resizable.js",
- "ui/button.js",
- "ui/effect.js",
- "ui/effect-blind.js",
- "ui/effect-explode.js",
- "ui/dialog.js"
- ]
- });
- </script>
-
- <script src="dialog_common.js"></script>
- <script src="dialog_core.js"></script>
- <script src="dialog_events.js"></script>
- <script src="dialog_methods.js"></script>
- <script src="dialog_options.js"></script>
- <script src="dialog_test_helpers.js"></script>
-
- <script src="../swarminject.js"></script>
+ <script src="../../lib/css.js" data-modules="core button dialog"></script>
+ <script src="../../lib/bootstrap.js" data-widget="dialog" data-no-back-compat="true"></script>
</head>
<body>
diff --git a/tests/unit/dialog/dialog_common.js b/tests/unit/dialog/dialog_common.js
index fc5105d74..389b2ddff 100644
--- a/tests/unit/dialog/dialog_common.js
+++ b/tests/unit/dialog/dialog_common.js
@@ -1,4 +1,9 @@
-TestHelpers.commonWidgetTests( "dialog", {
+define( [
+ "lib/common",
+ "ui/dialog"
+], function( common ) {
+
+common.testWidget( "dialog", {
defaults: {
appendTo: "body",
autoOpen: true,
@@ -44,3 +49,5 @@ TestHelpers.commonWidgetTests( "dialog", {
resizeStop: null
}
});
+
+} );
diff --git a/tests/unit/dialog/dialog_common_deprecated.js b/tests/unit/dialog/dialog_common_deprecated.js
index 30658696e..7b0091277 100644
--- a/tests/unit/dialog/dialog_common_deprecated.js
+++ b/tests/unit/dialog/dialog_common_deprecated.js
@@ -1,4 +1,9 @@
-TestHelpers.commonWidgetTests( "dialog", {
+define( [
+ "lib/common",
+ "ui/dialog"
+], function( common ) {
+
+common.testWidget( "dialog", {
defaults: {
appendTo: "body",
autoOpen: true,
@@ -45,3 +50,5 @@ TestHelpers.commonWidgetTests( "dialog", {
resizeStop: null
}
});
+
+} );
diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js
index 73d24fed0..cb086ce8d 100644
--- a/tests/unit/dialog/dialog_core.js
+++ b/tests/unit/dialog/dialog_core.js
@@ -1,8 +1,7 @@
-/*
- * dialog_core.js
- */
-
-(function($) {
+define( [
+ "jquery",
+ "ui/dialog"
+], function( $ ) {
// TODO add teardown callback to remove dialogs
module("dialog: core");
@@ -306,4 +305,4 @@ asyncTest( "interaction between overlay and other dialogs", function() {
});
});
-})(jQuery);
+} );
diff --git a/tests/unit/dialog/dialog_deprecated.html b/tests/unit/dialog/dialog_deprecated.html
index 5bcdf75e5..2d20b6291 100644
--- a/tests/unit/dialog/dialog_deprecated.html
+++ b/tests/unit/dialog/dialog_deprecated.html
@@ -4,41 +4,8 @@
<meta charset="utf-8">
<title>jQuery UI Dialog Test Suite</title>
- <script src="../../jquery.js"></script>
- <link rel="stylesheet" href="../../../external/qunit/qunit.css">
- <script src="../../../external/qunit/qunit.js"></script>
- <script src="../../../external/jquery-simulate/jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
- <script src="../../../external/qunit-assert-classes/qunit-assert-classes.js"></script>
- <script>
- TestHelpers.loadResources({
- css: [ "core", "dialog" ],
- js: [
- "ui/core.js",
- "ui/widget.js",
- "ui/position.js",
- "ui/mouse.js",
- "ui/draggable.js",
- "ui/resizable.js",
- "ui/button.js",
- "ui/effect.js",
- "ui/effect-blind.js",
- "ui/effect-clip.js",
- "ui/effect-explode.js",
- "ui/dialog.js"
- ]
- });
- </script>
-
- <script src="dialog_common_deprecated.js"></script>
- <script src="dialog_core.js"></script>
- <script src="dialog_events.js"></script>
- <script src="dialog_methods.js"></script>
- <script src="dialog_options.js"></script>
- <script src="dialog_deprecated.js"></script>
- <script src="dialog_test_helpers.js"></script>
-
- <script src="../swarminject.js"></script>
+ <script src="../../lib/css.js" data-modules="core button dialog"></script>
+ <script src="../../lib/bootstrap.js" data-widget="dialog" data-deprecated="true"></script>
</head>
<body>
diff --git a/tests/unit/dialog/dialog_deprecated.js b/tests/unit/dialog/dialog_deprecated.js
index 55c180457..1f7087c57 100644
--- a/tests/unit/dialog/dialog_deprecated.js
+++ b/tests/unit/dialog/dialog_deprecated.js
@@ -1,4 +1,7 @@
-(function( $ ) {
+define( [
+ "jquery",
+ "ui/dialog"
+], function( $ ) {
module( "dialog (deprecated): options" );
@@ -24,4 +27,4 @@ test( "dialogClass", function( assert ) {
element.remove();
});
-})( jQuery );
+} );
diff --git a/tests/unit/dialog/dialog_events.js b/tests/unit/dialog/dialog_events.js
index f4b353b8d..a6e4c0501 100644
--- a/tests/unit/dialog/dialog_events.js
+++ b/tests/unit/dialog/dialog_events.js
@@ -1,7 +1,8 @@
-/*
- * dialog_events.js
- */
-(function($) {
+define( [
+ "jquery",
+ "./dialog_test_helpers",
+ "ui/dialog"
+], function( $, dialogTestHelpers ) {
module("dialog: events");
@@ -103,7 +104,7 @@ test("dragStart", function() {
});
handle = $(".ui-dialog-titlebar", element.dialog("widget"));
- TestHelpers.dialog.drag(element, handle, 50, 50);
+ dialogTestHelpers.drag(element, handle, 50, 50);
element.remove();
});
@@ -131,7 +132,7 @@ test("drag", function() {
});
handle = $(".ui-dialog-titlebar", element.dialog("widget"));
- TestHelpers.dialog.drag(element, handle, 50, 50);
+ dialogTestHelpers.drag(element, handle, 50, 50);
element.remove();
});
@@ -155,7 +156,7 @@ test("dragStop", function() {
});
handle = $(".ui-dialog-titlebar", element.dialog("widget"));
- TestHelpers.dialog.drag(element, handle, 50, 50);
+ dialogTestHelpers.drag(element, handle, 50, 50);
element.remove();
});
@@ -183,7 +184,7 @@ test("resizeStart", function() {
});
handle = $(".ui-resizable-se", element.dialog("widget"));
- TestHelpers.dialog.drag(element, handle, 50, 50);
+ dialogTestHelpers.drag(element, handle, 50, 50);
element.remove();
});
@@ -215,7 +216,7 @@ test("resize", function() {
});
handle = $(".ui-resizable-se", element.dialog("widget"));
- TestHelpers.dialog.drag(element, handle, 50, 50);
+ dialogTestHelpers.drag(element, handle, 50, 50);
element.remove();
});
@@ -243,7 +244,7 @@ test("resizeStop", function() {
});
handle = $(".ui-resizable-se", element.dialog("widget"));
- TestHelpers.dialog.drag(element, handle, 50, 50);
+ dialogTestHelpers.drag(element, handle, 50, 50);
element.remove();
});
@@ -366,4 +367,4 @@ test("ensure dialog keeps focus when clicking modal overlay", function() {
element.remove();
});
-})(jQuery);
+} );
diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js
index c92f1f1b4..10b0fd7bb 100644
--- a/tests/unit/dialog/dialog_methods.js
+++ b/tests/unit/dialog/dialog_methods.js
@@ -1,7 +1,7 @@
-/*
- * dialog_methods.js
- */
-(function($) {
+define( [
+ "jquery",
+ "ui/dialog"
+], function( $ ) {
module("dialog: methods", {
teardown: function() {
@@ -33,18 +33,18 @@ test("init", function() {
ok(true, "arbitrary option setter after init");
});
-test("destroy", function() {
+test("destroy", function( assert ) {
expect( 17 );
var element, element2;
$( "#dialog1, #form-dialog" ).hide();
- domEqual( "#dialog1", function() {
+ assert.domEqual( "#dialog1", function() {
var dialog = $( "#dialog1" ).dialog().dialog( "destroy" );
equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] );
equal( dialog.index(), 0 );
});
- domEqual( "#form-dialog", function() {
+ assert.domEqual( "#form-dialog", function() {
var dialog = $( "#form-dialog" ).dialog().dialog( "destroy" );
equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] );
equal( dialog.index(), 2 );
@@ -56,7 +56,7 @@ test("destroy", function() {
minHeight: "100px",
height: "200px"
});
- domEqual( "#dialog1", function() {
+ assert.domEqual( "#dialog1", function() {
$( "#dialog1" ).dialog().dialog( "destroy" );
});
@@ -264,4 +264,4 @@ test("#5531: dialog width should be at least minWidth on creation", function ()
});
-})(jQuery);
+} );
diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js
index 1c3648f11..e4ff6ac72 100644
--- a/tests/unit/dialog/dialog_options.js
+++ b/tests/unit/dialog/dialog_options.js
@@ -1,7 +1,10 @@
-/*
- * dialog_options.js
- */
-(function($) {
+define( [
+ "jquery",
+ "./dialog_test_helpers",
+ "ui/dialog",
+ "ui/effect-blind",
+ "ui/effect-explode"
+], function( $, dialogTestHelpers ) {
module("dialog: options");
@@ -228,15 +231,15 @@ test("draggable", function() {
var element = $("<div></div>").dialog({ draggable: false });
- TestHelpers.dialog.testDrag(element, 50, -50, 0, 0);
+ dialogTestHelpers.testDrag(element, 50, -50, 0, 0);
element.dialog("option", "draggable", true);
- TestHelpers.dialog.testDrag(element, 50, -50, 50, -50);
+ dialogTestHelpers.testDrag(element, 50, -50, 50, -50);
element.remove();
element = $("<div></div>").dialog({ draggable: true });
- TestHelpers.dialog.testDrag(element, 50, -50, 50, -50);
+ dialogTestHelpers.testDrag(element, 50, -50, 50, -50);
element.dialog("option", "draggable", false);
- TestHelpers.dialog.testDrag(element, 50, -50, 0, 0);
+ dialogTestHelpers.testDrag(element, 50, -50, 0, 0);
element.remove();
});
@@ -266,17 +269,17 @@ test("maxHeight", function( assert ) {
expect(3);
var element = $("<div></div>").dialog({ maxHeight: 200 });
- TestHelpers.dialog.drag(element, ".ui-resizable-s", 1000, 1000);
+ dialogTestHelpers.drag(element, ".ui-resizable-s", 1000, 1000);
assert.close(element.dialog("widget").height(), 200, 1, "maxHeight");
element.remove();
element = $("<div></div>").dialog({ maxHeight: 200 });
- TestHelpers.dialog.drag(element, ".ui-resizable-n", -1000, -1000);
+ dialogTestHelpers.drag(element, ".ui-resizable-n", -1000, -1000);
assert.close(element.dialog("widget").height(), 200, 1, "maxHeight");
element.remove();
element = $("<div></div>").dialog({ maxHeight: 200 }).dialog("option", "maxHeight", 300);
- TestHelpers.dialog.drag(element, ".ui-resizable-s", 1000, 1000);
+ dialogTestHelpers.drag(element, ".ui-resizable-s", 1000, 1000);
assert.close(element.dialog("widget").height(), 300, 1, "maxHeight");
element.remove();
});
@@ -285,17 +288,17 @@ test("maxWidth", function( assert ) {
expect(3);
var element = $("<div></div>").dialog({ maxWidth: 200 });
- TestHelpers.dialog.drag(element, ".ui-resizable-e", 1000, 1000);
+ dialogTestHelpers.drag(element, ".ui-resizable-e", 1000, 1000);
assert.close(element.dialog("widget").width(), 200, 1, "maxWidth");
element.remove();
element = $("<div></div>").dialog({ maxWidth: 200 });
- TestHelpers.dialog.drag(element, ".ui-resizable-w", -1000, -1000);
+ dialogTestHelpers.drag(element, ".ui-resizable-w", -1000, -1000);
assert.close(element.dialog("widget").width(), 200, 1, "maxWidth");
element.remove();
element = $("<div></div>").dialog({ maxWidth: 200 }).dialog("option", "maxWidth", 300);
- TestHelpers.dialog.drag(element, ".ui-resizable-w", -1000, -1000);
+ dialogTestHelpers.drag(element, ".ui-resizable-w", -1000, -1000);
assert.close(element.dialog("widget").width(), 300, 1, "maxWidth");
element.remove();
});
@@ -304,17 +307,17 @@ test("minHeight", function( assert ) {
expect(3);
var element = $("<div></div>").dialog({ minHeight: 10 });
- TestHelpers.dialog.drag(element, ".ui-resizable-s", -1000, -1000);
+ dialogTestHelpers.drag(element, ".ui-resizable-s", -1000, -1000);
assert.close(element.dialog("widget").height(), 10, 1, "minHeight");
element.remove();
element = $("<div></div>").dialog({ minHeight: 10 });
- TestHelpers.dialog.drag(element, ".ui-resizable-n", 1000, 1000);
+ dialogTestHelpers.drag(element, ".ui-resizable-n", 1000, 1000);
assert.close(element.dialog("widget").height(), 10, 1, "minHeight");
element.remove();
element = $("<div></div>").dialog({ minHeight: 10 }).dialog("option", "minHeight", 30);
- TestHelpers.dialog.drag(element, ".ui-resizable-n", 1000, 1000);
+ dialogTestHelpers.drag(element, ".ui-resizable-n", 1000, 1000);
assert.close(element.dialog("widget").height(), 30, 1, "minHeight");
element.remove();
});
@@ -323,17 +326,17 @@ test("minWidth", function( assert ) {
expect(3);
var element = $("<div></div>").dialog({ minWidth: 10 });
- TestHelpers.dialog.drag(element, ".ui-resizable-e", -1000, -1000);
+ dialogTestHelpers.drag(element, ".ui-resizable-e", -1000, -1000);
assert.close(element.dialog("widget").width(), 10, 1, "minWidth");
element.remove();
element = $("<div></div>").dialog({ minWidth: 10 });
- TestHelpers.dialog.drag(element, ".ui-resizable-w", 1000, 1000);
+ dialogTestHelpers.drag(element, ".ui-resizable-w", 1000, 1000);
assert.close(element.dialog("widget").width(), 10, 1, "minWidth");
element.remove();
element = $("<div></div>").dialog({ minWidth: 30 }).dialog("option", "minWidth", 30);
- TestHelpers.dialog.drag(element, ".ui-resizable-w", 1000, 1000);
+ dialogTestHelpers.drag(element, ".ui-resizable-w", 1000, 1000);
assert.close(element.dialog("widget").width(), 30, 1, "minWidth");
element.remove();
});
@@ -421,15 +424,15 @@ test("resizable", function() {
expect(4);
var element = $("<div></div>").dialog();
- TestHelpers.dialog.shouldResize(element, 50, 50, "[default]");
+ dialogTestHelpers.shouldResize(element, 50, 50, "[default]");
element.dialog("option", "resizable", false);
- TestHelpers.dialog.shouldResize(element, 0, 0, "disabled after init");
+ dialogTestHelpers.shouldResize(element, 0, 0, "disabled after init");
element.remove();
element = $("<div></div>").dialog({ resizable: false });
- TestHelpers.dialog.shouldResize(element, 0, 0, "disabled in init options");
+ dialogTestHelpers.shouldResize(element, 0, 0, "disabled in init options");
element.dialog("option", "resizable", true);
- TestHelpers.dialog.shouldResize(element, 50, 50, "enabled after init");
+ dialogTestHelpers.shouldResize(element, 50, 50, "enabled after init");
element.remove();
});
@@ -494,18 +497,18 @@ test("#4826: setting resizable false toggles resizable on dialog", function() {
var i,
element = $("<div></div>").dialog({ resizable: false });
- TestHelpers.dialog.shouldResize(element, 0, 0, "[default]");
+ dialogTestHelpers.shouldResize(element, 0, 0, "[default]");
for (i=0; i<2; i++) {
element.dialog("close").dialog("open");
- TestHelpers.dialog.shouldResize(element, 0, 0, "initialized with resizable false toggle ("+ (i+1) +")");
+ dialogTestHelpers.shouldResize(element, 0, 0, "initialized with resizable false toggle ("+ (i+1) +")");
}
element.remove();
element = $("<div></div>").dialog({ resizable: true });
- TestHelpers.dialog.shouldResize(element, 50, 50, "[default]");
+ dialogTestHelpers.shouldResize(element, 50, 50, "[default]");
for (i=0; i<2; i++) {
element.dialog("close").dialog("option", "resizable", false).dialog("open");
- TestHelpers.dialog.shouldResize(element, 0, 0, "set option resizable false toggle ("+ (i+1) +")");
+ dialogTestHelpers.shouldResize(element, 0, 0, "set option resizable false toggle ("+ (i+1) +")");
}
element.remove();
@@ -551,4 +554,4 @@ asyncTest( "Open followed by close during show effect", function() {
}, 100 );
});
-})(jQuery);
+} );
diff --git a/tests/unit/dialog/dialog_test_helpers.js b/tests/unit/dialog/dialog_test_helpers.js
index 705eb3010..f11c77cde 100644
--- a/tests/unit/dialog/dialog_test_helpers.js
+++ b/tests/unit/dialog/dialog_test_helpers.js
@@ -1,4 +1,6 @@
-TestHelpers.dialog = {
+define( function() {
+
+var dialogTestHelpers = {
drag: function(element, handle, dx, dy) {
var d = element.dialog("widget");
//this mouseover is to work around a limitation in resizable
@@ -14,7 +16,7 @@ TestHelpers.dialog = {
handle = $(".ui-dialog-titlebar", d),
offsetBefore = d.offset();
- TestHelpers.dialog.drag(element, handle, dx, dy);
+ dialogTestHelpers.drag(element, handle, dx, dy);
offsetAfter = d.offset();
@@ -34,7 +36,7 @@ TestHelpers.dialog = {
heightBefore = element.height(),
widthBefore = element.width();
- TestHelpers.dialog.drag(element, handle, 50, 50);
+ dialogTestHelpers.drag(element, handle, 50, 50);
heightAfter = element.height();
widthAfter = element.width();
@@ -45,3 +47,7 @@ TestHelpers.dialog = {
deepEqual(actual, expected, "resized[" + 50 + ", " + 50 + "] " + msg);
}
};
+
+return dialogTestHelpers;
+
+} );