Skip to content

Commit 7d48112

Browse files
committed
Dialog: Convert tests to new infrastructure
Ref #10119 Ref jquerygh-1528
1 parent 0714f55 commit 7d48112

10 files changed

+92
-133
lines changed

tests/unit/dialog/dialog.html

+2-36
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,8 @@
44
<meta charset="utf-8">
55
<title>jQuery UI Dialog Test Suite</title>
66

7-
<script src="../../jquery.js"></script>
8-
<script>
9-
$.uiBackCompat = false;
10-
</script>
11-
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
12-
<script src="../../../external/qunit/qunit.js"></script>
13-
<script src="../../../external/jquery-simulate/jquery.simulate.js"></script>
14-
<script src="../testsuite.js"></script>
15-
<script src="../../../external/qunit-assert-classes/qunit-assert-classes.js"></script>
16-
<script>
17-
TestHelpers.loadResources({
18-
css: [ "core", "dialog" ],
19-
js: [
20-
"ui/core.js",
21-
"ui/widget.js",
22-
"ui/position.js",
23-
"ui/mouse.js",
24-
"ui/draggable.js",
25-
"ui/resizable.js",
26-
"ui/button.js",
27-
"ui/effect.js",
28-
"ui/effect-blind.js",
29-
"ui/effect-explode.js",
30-
"ui/dialog.js"
31-
]
32-
});
33-
</script>
34-
35-
<script src="dialog_common.js"></script>
36-
<script src="dialog_core.js"></script>
37-
<script src="dialog_events.js"></script>
38-
<script src="dialog_methods.js"></script>
39-
<script src="dialog_options.js"></script>
40-
<script src="dialog_test_helpers.js"></script>
41-
42-
<script src="../swarminject.js"></script>
7+
<script src="../../lib/css.js" data-modules="core button dialog"></script>
8+
<script src="../../lib/bootstrap.js" data-widget="dialog" data-no-back-compat="true"></script>
439
</head>
4410
<body>
4511

tests/unit/dialog/dialog_common.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
TestHelpers.commonWidgetTests( "dialog", {
1+
define( [
2+
"lib/common",
3+
"ui/dialog"
4+
], function( common ) {
5+
6+
common.testWidget( "dialog", {
27
defaults: {
38
appendTo: "body",
49
autoOpen: true,
@@ -44,3 +49,5 @@ TestHelpers.commonWidgetTests( "dialog", {
4449
resizeStop: null
4550
}
4651
});
52+
53+
} );

tests/unit/dialog/dialog_common_deprecated.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
TestHelpers.commonWidgetTests( "dialog", {
1+
define( [
2+
"lib/common",
3+
"ui/dialog"
4+
], function( common ) {
5+
6+
common.testWidget( "dialog", {
27
defaults: {
38
appendTo: "body",
49
autoOpen: true,
@@ -45,3 +50,5 @@ TestHelpers.commonWidgetTests( "dialog", {
4550
resizeStop: null
4651
}
4752
});
53+
54+
} );

tests/unit/dialog/dialog_core.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
/*
2-
* dialog_core.js
3-
*/
4-
5-
(function($) {
1+
define( [
2+
"jquery",
3+
"ui/dialog"
4+
], function( $ ) {
65

76
// TODO add teardown callback to remove dialogs
87
module("dialog: core");
@@ -306,4 +305,4 @@ asyncTest( "interaction between overlay and other dialogs", function() {
306305
});
307306
});
308307

309-
})(jQuery);
308+
} );

tests/unit/dialog/dialog_deprecated.html

+2-35
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,8 @@
44
<meta charset="utf-8">
55
<title>jQuery UI Dialog Test Suite</title>
66

7-
<script src="../../jquery.js"></script>
8-
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
9-
<script src="../../../external/qunit/qunit.js"></script>
10-
<script src="../../../external/jquery-simulate/jquery.simulate.js"></script>
11-
<script src="../testsuite.js"></script>
12-
<script src="../../../external/qunit-assert-classes/qunit-assert-classes.js"></script>
13-
<script>
14-
TestHelpers.loadResources({
15-
css: [ "core", "dialog" ],
16-
js: [
17-
"ui/core.js",
18-
"ui/widget.js",
19-
"ui/position.js",
20-
"ui/mouse.js",
21-
"ui/draggable.js",
22-
"ui/resizable.js",
23-
"ui/button.js",
24-
"ui/effect.js",
25-
"ui/effect-blind.js",
26-
"ui/effect-clip.js",
27-
"ui/effect-explode.js",
28-
"ui/dialog.js"
29-
]
30-
});
31-
</script>
32-
33-
<script src="dialog_common_deprecated.js"></script>
34-
<script src="dialog_core.js"></script>
35-
<script src="dialog_events.js"></script>
36-
<script src="dialog_methods.js"></script>
37-
<script src="dialog_options.js"></script>
38-
<script src="dialog_deprecated.js"></script>
39-
<script src="dialog_test_helpers.js"></script>
40-
41-
<script src="../swarminject.js"></script>
7+
<script src="../../lib/css.js" data-modules="core button dialog"></script>
8+
<script src="../../lib/bootstrap.js" data-widget="dialog" data-deprecated="true"></script>
429
</head>
4310
<body>
4411

tests/unit/dialog/dialog_deprecated.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
(function( $ ) {
1+
define( [
2+
"jquery",
3+
"ui/dialog"
4+
], function( $ ) {
25

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

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

27-
})( jQuery );
30+
} );

tests/unit/dialog/dialog_events.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
/*
2-
* dialog_events.js
3-
*/
4-
(function($) {
1+
define( [
2+
"jquery",
3+
"./dialog_test_helpers",
4+
"ui/dialog"
5+
], function( $, dialogTestHelpers ) {
56

67
module("dialog: events");
78

@@ -103,7 +104,7 @@ test("dragStart", function() {
103104
});
104105

105106
handle = $(".ui-dialog-titlebar", element.dialog("widget"));
106-
TestHelpers.dialog.drag(element, handle, 50, 50);
107+
dialogTestHelpers.drag(element, handle, 50, 50);
107108
element.remove();
108109
});
109110

@@ -131,7 +132,7 @@ test("drag", function() {
131132
});
132133

133134
handle = $(".ui-dialog-titlebar", element.dialog("widget"));
134-
TestHelpers.dialog.drag(element, handle, 50, 50);
135+
dialogTestHelpers.drag(element, handle, 50, 50);
135136
element.remove();
136137
});
137138

@@ -155,7 +156,7 @@ test("dragStop", function() {
155156
});
156157

157158
handle = $(".ui-dialog-titlebar", element.dialog("widget"));
158-
TestHelpers.dialog.drag(element, handle, 50, 50);
159+
dialogTestHelpers.drag(element, handle, 50, 50);
159160
element.remove();
160161
});
161162

@@ -183,7 +184,7 @@ test("resizeStart", function() {
183184
});
184185

185186
handle = $(".ui-resizable-se", element.dialog("widget"));
186-
TestHelpers.dialog.drag(element, handle, 50, 50);
187+
dialogTestHelpers.drag(element, handle, 50, 50);
187188
element.remove();
188189
});
189190

@@ -215,7 +216,7 @@ test("resize", function() {
215216
});
216217

217218
handle = $(".ui-resizable-se", element.dialog("widget"));
218-
TestHelpers.dialog.drag(element, handle, 50, 50);
219+
dialogTestHelpers.drag(element, handle, 50, 50);
219220
element.remove();
220221
});
221222

@@ -243,7 +244,7 @@ test("resizeStop", function() {
243244
});
244245

245246
handle = $(".ui-resizable-se", element.dialog("widget"));
246-
TestHelpers.dialog.drag(element, handle, 50, 50);
247+
dialogTestHelpers.drag(element, handle, 50, 50);
247248
element.remove();
248249
});
249250

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

369-
})(jQuery);
370+
} );

tests/unit/dialog/dialog_methods.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/*
2-
* dialog_methods.js
3-
*/
4-
(function($) {
1+
define( [
2+
"jquery",
3+
"ui/dialog"
4+
], function( $ ) {
55

66
module("dialog: methods", {
77
teardown: function() {
@@ -33,18 +33,18 @@ test("init", function() {
3333
ok(true, "arbitrary option setter after init");
3434
});
3535

36-
test("destroy", function() {
36+
test("destroy", function( assert ) {
3737
expect( 17 );
3838

3939
var element, element2;
4040

4141
$( "#dialog1, #form-dialog" ).hide();
42-
domEqual( "#dialog1", function() {
42+
assert.domEqual( "#dialog1", function() {
4343
var dialog = $( "#dialog1" ).dialog().dialog( "destroy" );
4444
equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] );
4545
equal( dialog.index(), 0 );
4646
});
47-
domEqual( "#form-dialog", function() {
47+
assert.domEqual( "#form-dialog", function() {
4848
var dialog = $( "#form-dialog" ).dialog().dialog( "destroy" );
4949
equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] );
5050
equal( dialog.index(), 2 );
@@ -56,7 +56,7 @@ test("destroy", function() {
5656
minHeight: "100px",
5757
height: "200px"
5858
});
59-
domEqual( "#dialog1", function() {
59+
assert.domEqual( "#dialog1", function() {
6060
$( "#dialog1" ).dialog().dialog( "destroy" );
6161
});
6262

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

265265
});
266266

267-
})(jQuery);
267+
} );

0 commit comments

Comments
 (0)