Skip to content

Commit

Permalink
Dialog: Convert tests to new infrastructure
Browse files Browse the repository at this point in the history
Ref #10119
Ref gh-1528
  • Loading branch information
scottgonzalez committed Apr 9, 2015
1 parent 0714f55 commit 7d48112
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 133 deletions.
38 changes: 2 additions & 36 deletions tests/unit/dialog/dialog.html
Expand Up @@ -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>

Expand Down
9 changes: 8 additions & 1 deletion 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,
Expand Down Expand Up @@ -44,3 +49,5 @@ TestHelpers.commonWidgetTests( "dialog", {
resizeStop: null
}
});

} );
9 changes: 8 additions & 1 deletion 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,
Expand Down Expand Up @@ -45,3 +50,5 @@ TestHelpers.commonWidgetTests( "dialog", {
resizeStop: null
}
});

} );
11 changes: 5 additions & 6 deletions 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");
Expand Down Expand Up @@ -306,4 +305,4 @@ asyncTest( "interaction between overlay and other dialogs", function() {
});
});

})(jQuery);
} );
37 changes: 2 additions & 35 deletions tests/unit/dialog/dialog_deprecated.html
Expand Up @@ -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>

Expand Down
7 changes: 5 additions & 2 deletions tests/unit/dialog/dialog_deprecated.js
@@ -1,4 +1,7 @@
(function( $ ) {
define( [
"jquery",
"ui/dialog"
], function( $ ) {

module( "dialog (deprecated): options" );

Expand All @@ -24,4 +27,4 @@ test( "dialogClass", function( assert ) {
element.remove();
});

})( jQuery );
} );
23 changes: 12 additions & 11 deletions 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");

Expand Down Expand Up @@ -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();
});

Expand Down Expand Up @@ -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();
});

Expand All @@ -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();
});

Expand Down Expand Up @@ -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();
});

Expand Down Expand Up @@ -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();
});

Expand Down Expand Up @@ -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();
});

Expand Down Expand Up @@ -366,4 +367,4 @@ test("ensure dialog keeps focus when clicking modal overlay", function() {
element.remove();
});

})(jQuery);
} );
18 changes: 9 additions & 9 deletions tests/unit/dialog/dialog_methods.js
@@ -1,7 +1,7 @@
/*
* dialog_methods.js
*/
(function($) {
define( [
"jquery",
"ui/dialog"
], function( $ ) {

module("dialog: methods", {
teardown: function() {
Expand Down Expand Up @@ -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 );
Expand All @@ -56,7 +56,7 @@ test("destroy", function() {
minHeight: "100px",
height: "200px"
});
domEqual( "#dialog1", function() {
assert.domEqual( "#dialog1", function() {
$( "#dialog1" ).dialog().dialog( "destroy" );
});

Expand Down Expand Up @@ -264,4 +264,4 @@ test("#5531: dialog width should be at least minWidth on creation", function ()

});

})(jQuery);
} );

0 comments on commit 7d48112

Please sign in to comment.