Skip to content

Commit 0290325

Browse files
committed
Tests: Created a composite test suite.
1 parent f890911 commit 0290325

File tree

2 files changed

+127
-0
lines changed

2 files changed

+127
-0
lines changed

tests/unit/all.html

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>jQuery UI Test Suite</title>
6+
7+
<script src="../../jquery-1.6.2.js"></script>
8+
9+
<link rel="stylesheet" href="../../external/qunit.css">
10+
<script src="../../external/qunit.js"></script>
11+
<script src="testsuites.js"></script>
12+
13+
<script>
14+
QUnit.testSuites([
15+
"accordion/accordion.html",
16+
"accordion/accordion_deprecated.html",
17+
"autocomplete/autocomplete.html",
18+
"button/button.html",
19+
"core/core.html",
20+
"datepicker/datepicker.html",
21+
"dialog/dialog.html",
22+
//"draggable/draggable.html",
23+
//"droppable/droppable.html",
24+
"effects/effects.html",
25+
"menu/menu.html",
26+
"position/position.html",
27+
"progressbar/progressbar.html",
28+
//"resizable/resizable.html",
29+
//"selectable/selectable.html",
30+
"slider/slider.html",
31+
//"sortable/sortable.html",
32+
"spinner/spinner.html",
33+
"tabs/tabs.html",
34+
"tabs/tabs_deprecated.html",
35+
"tooltip/tooltip.html",
36+
"widget/widget.html"
37+
]);
38+
</script>
39+
</head>
40+
<body>
41+
42+
<h1 id="qunit-header">jQuery UI Test Suite</h1>
43+
<h2 id="qunit-banner"></h2>
44+
<div id="qunit-testrunner-toolbar"></div>
45+
<h2 id="qunit-userAgent"></h2>
46+
<ol id="qunit-tests"></ol>
47+
<div id="qunit-fixture">
48+
49+
</div>
50+
</body>
51+
</html>

tests/unit/testsuites.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
(function( $, QUnit ) {
2+
3+
$.extend( QUnit, {
4+
testSuites: function( suites ) {
5+
$.each( suites, function( i, suite ) {
6+
asyncTest( suite, function() {
7+
runSuite( suite );
8+
});
9+
});
10+
},
11+
12+
testStart: function( data ) {
13+
// update the test status to show which test suite is running
14+
$( "#qunit-testresult" ).html( "Running " + data.name + "...<br>&nbsp;" );
15+
},
16+
17+
testDone: function() {
18+
// undo the auto-expansion of failed tests
19+
$( "#qunit-tests > li.fail" ).each(function() {
20+
var test = $( this );
21+
// avoid collapsing test results that the user manually opened
22+
if ( test.data( "auto-collapsed" ) ) {
23+
return;
24+
}
25+
test.data( "auto-collapsed", true )
26+
.children( "ol" ).hide();
27+
});
28+
}
29+
});
30+
31+
// generate an iframe to run the test suite and proxy the iframe's QUnit
32+
// to pass all test info to the main page
33+
function runSuite( suite ) {
34+
var body = $( "body" ),
35+
iframe = $( "<iframe>", { src: suite } )
36+
.css({
37+
width: 1000,
38+
height: 1000
39+
})
40+
.appendTo( body )
41+
[0],
42+
iframeWin = iframe.contentWindow;
43+
44+
$( iframeWin ).bind( "load", function() {
45+
var module, test,
46+
count = 0;
47+
48+
$.extend( iframeWin.QUnit, {
49+
moduleStart: function( data ) {
50+
// capture module name for messages
51+
module = data.name;
52+
},
53+
54+
testStart: function( data ) {
55+
// capture test name for messages
56+
test = data.name;
57+
},
58+
59+
log: function( data ) {
60+
// pass all test details through to the main page
61+
var message = module + ": " + test + ": " + data.message;
62+
expect( ++count );
63+
QUnit.push( data.result, data.actual, data.expected, message );
64+
},
65+
66+
done: function() {
67+
// hide the iframe from the main page once the tests are done
68+
// and start the wrapper test from the main page
69+
$( iframe ).hide();
70+
start();
71+
}
72+
});
73+
});
74+
}
75+
76+
}( jQuery, QUnit ) );

0 commit comments

Comments
 (0)