mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Tests: Created a composite test suite.
This commit is contained in:
parent
f89091105f
commit
02903259e1
51
tests/unit/all.html
Normal file
51
tests/unit/all.html
Normal file
@ -0,0 +1,51 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery UI Test Suite</title>
|
||||
|
||||
<script src="../../jquery-1.6.2.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="../../external/qunit.css">
|
||||
<script src="../../external/qunit.js"></script>
|
||||
<script src="testsuites.js"></script>
|
||||
|
||||
<script>
|
||||
QUnit.testSuites([
|
||||
"accordion/accordion.html",
|
||||
"accordion/accordion_deprecated.html",
|
||||
"autocomplete/autocomplete.html",
|
||||
"button/button.html",
|
||||
"core/core.html",
|
||||
"datepicker/datepicker.html",
|
||||
"dialog/dialog.html",
|
||||
//"draggable/draggable.html",
|
||||
//"droppable/droppable.html",
|
||||
"effects/effects.html",
|
||||
"menu/menu.html",
|
||||
"position/position.html",
|
||||
"progressbar/progressbar.html",
|
||||
//"resizable/resizable.html",
|
||||
//"selectable/selectable.html",
|
||||
"slider/slider.html",
|
||||
//"sortable/sortable.html",
|
||||
"spinner/spinner.html",
|
||||
"tabs/tabs.html",
|
||||
"tabs/tabs_deprecated.html",
|
||||
"tooltip/tooltip.html",
|
||||
"widget/widget.html"
|
||||
]);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1 id="qunit-header">jQuery UI Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture">
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
76
tests/unit/testsuites.js
Normal file
76
tests/unit/testsuites.js
Normal file
@ -0,0 +1,76 @@
|
||||
(function( $, QUnit ) {
|
||||
|
||||
$.extend( QUnit, {
|
||||
testSuites: function( suites ) {
|
||||
$.each( suites, function( i, suite ) {
|
||||
asyncTest( suite, function() {
|
||||
runSuite( suite );
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
testStart: function( data ) {
|
||||
// update the test status to show which test suite is running
|
||||
$( "#qunit-testresult" ).html( "Running " + data.name + "...<br> " );
|
||||
},
|
||||
|
||||
testDone: function() {
|
||||
// undo the auto-expansion of failed tests
|
||||
$( "#qunit-tests > li.fail" ).each(function() {
|
||||
var test = $( this );
|
||||
// avoid collapsing test results that the user manually opened
|
||||
if ( test.data( "auto-collapsed" ) ) {
|
||||
return;
|
||||
}
|
||||
test.data( "auto-collapsed", true )
|
||||
.children( "ol" ).hide();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// generate an iframe to run the test suite and proxy the iframe's QUnit
|
||||
// to pass all test info to the main page
|
||||
function runSuite( suite ) {
|
||||
var body = $( "body" ),
|
||||
iframe = $( "<iframe>", { src: suite } )
|
||||
.css({
|
||||
width: 1000,
|
||||
height: 1000
|
||||
})
|
||||
.appendTo( body )
|
||||
[0],
|
||||
iframeWin = iframe.contentWindow;
|
||||
|
||||
$( iframeWin ).bind( "load", function() {
|
||||
var module, test,
|
||||
count = 0;
|
||||
|
||||
$.extend( iframeWin.QUnit, {
|
||||
moduleStart: function( data ) {
|
||||
// capture module name for messages
|
||||
module = data.name;
|
||||
},
|
||||
|
||||
testStart: function( data ) {
|
||||
// capture test name for messages
|
||||
test = data.name;
|
||||
},
|
||||
|
||||
log: function( data ) {
|
||||
// pass all test details through to the main page
|
||||
var message = module + ": " + test + ": " + data.message;
|
||||
expect( ++count );
|
||||
QUnit.push( data.result, data.actual, data.expected, message );
|
||||
},
|
||||
|
||||
done: function() {
|
||||
// hide the iframe from the main page once the tests are done
|
||||
// and start the wrapper test from the main page
|
||||
$( iframe ).hide();
|
||||
start();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}( jQuery, QUnit ) );
|
Loading…
Reference in New Issue
Block a user