diff options
author | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2011-07-27 15:42:41 +0200 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2011-07-27 15:42:41 +0200 |
commit | 4de759ddd203b5770e17aa9dca044e5b0bb8dacc (patch) | |
tree | 6b642d9fe4f4d3e6edaaa6e8a86410582f9a108f /tests/unit/testsuites.js | |
parent | a40182917ead3b866d747d30f68b7dd378c1787b (diff) | |
parent | 3c65bc39236a4d73cb13dc4f5dca6fc0129d8460 (diff) | |
download | jquery-ui-4de759ddd203b5770e17aa9dca044e5b0bb8dacc.tar.gz jquery-ui-4de759ddd203b5770e17aa9dca044e5b0bb8dacc.zip |
Merge branch 'master' of github.com:jquery/jquery-ui
Diffstat (limited to 'tests/unit/testsuites.js')
-rw-r--r-- | tests/unit/testsuites.js | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/unit/testsuites.js b/tests/unit/testsuites.js new file mode 100644 index 000000000..ffe2d3cc0 --- /dev/null +++ b/tests/unit/testsuites.js @@ -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 ) ); |