]> source.dussan.org Git - jquery-ui.git/commitdiff
Dialog: Convert tests to new infrastructure
authorScott González <scott.gonzalez@gmail.com>
Tue, 7 Apr 2015 00:23:50 +0000 (20:23 -0400)
committerScott González <scott.gonzalez@gmail.com>
Thu, 9 Apr 2015 13:26:27 +0000 (09:26 -0400)
Ref #10119
Ref gh-1528

tests/unit/dialog/dialog.html
tests/unit/dialog/dialog_common.js
tests/unit/dialog/dialog_common_deprecated.js
tests/unit/dialog/dialog_core.js
tests/unit/dialog/dialog_deprecated.html
tests/unit/dialog/dialog_deprecated.js
tests/unit/dialog/dialog_events.js
tests/unit/dialog/dialog_methods.js
tests/unit/dialog/dialog_options.js
tests/unit/dialog/dialog_test_helpers.js

index 5434e6bfc3bec1916de188ce24df9fe1123fc3bf..aa0e3d3ec1cf6f18776aa1fabe57c518a4f78e74 100644 (file)
@@ -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>
 
index fc5105d743700a56f0336089cb1c8957e9afb51e..389b2ddff784ccab84cb097c02d52a259b3df7b9 100644 (file)
@@ -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
        }
 });
+
+} );
index 30658696e0b34302735323c7353b3c1179f45906..7b00912779b9a8761a23249ed59c6ff89899d008 100644 (file)
@@ -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
        }
 });
+
+} );
index 73d24fed0af76300785afb3df63999cd0fbdd69b..cb086ce8defeb86fb17fae106c376e2f5237e377 100644 (file)
@@ -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);
+} );
index 5bcdf75e57b09324aebf8ac0ace460cd9790b742..2d20b62914c52f86bfd85c852667588e08653bfe 100644 (file)
@@ -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>
 
index 55c1804573956ba02449b43571c90d1cc4da07d4..1f7087c57ee1a36dad068a1159bdbcd02abc2404 100644 (file)
@@ -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 );
+} );
index f4b353b8dd459eb728d05aede1172beb2e629d63..a6e4c0501b457be7b58f4aeee31f14616f6f7197 100644 (file)
@@ -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);
+} );
index c92f1f1b4a7a1d85753c707419b03b2012d05fe3..10b0fd7bb957a4f87ab0b6fad0543d627c575982 100644 (file)
@@ -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);
+} );
index 1c3648f111d5fcc567b3f58686c4e5db9a6baf80..e4ff6ac7202b9203357ac8771e604a3c790df076 100644 (file)
@@ -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);
+} );
index 705eb3010be02a91936feb3b944c81c1ccd243d5..f11c77cded460326c6848169ce34b38b083115ab 100644 (file)
@@ -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;
+
+} );