X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;ds=inline;f=test%2Fdata%2Ftestrunner.js;h=d4fdcf50f06a95797e1f276569a61e388d13c49e;hb=54867a98033d7c1d2811308861ea5a92ef80ad4b;hp=7b7779a5be3ea87654bf4cc052a67736ca690935;hpb=3a4e1233aa2acabee0d0267d54c2d1112fbdcad4;p=jquery.git diff --git a/test/data/testrunner.js b/test/data/testrunner.js index 7b7779a..d4fdcf5 100644 --- a/test/data/testrunner.js +++ b/test/data/testrunner.js @@ -13,6 +13,9 @@ var _config = { asyncTimeout: 2 // seconds for async timeout }; +_config.filters = location.search.length > 1 && //restrict modules/tests by get parameters + $.map( location.search.slice(1).split('&'), decodeURIComponent ); + var isLocal = !!(window.location.protocol == 'file:'); $(function() { @@ -54,10 +57,31 @@ function start() { }, 13); } +function validTest( name ) { + var filters = _config.filters; + if( !filters ) + return true; + + var i = filters.length, + run = false; + while( i-- ){ + var filter = filters[i], + not = filter.charAt(0) == '!'; + if( not ) + filter = filter.slice(1); + if( name.indexOf(filter) != -1 ) + return !not; + if( not ) + run = true; + } + return run; +} + function runTest() { _config.blocking = false; var time = new Date(); _config.fixture = document.getElementById('main').innerHTML; + _config.ajaxSettings = $.ajaxSettings; synchronize(function() { time = new Date() - time; $("
Tests completed in ', @@ -73,8 +97,7 @@ function test(name, callback, nowait) { if(_config.currentModule) name = _config.currentModule + " module: " + name; - var filter = location.search.slice(1); - if ( filter && encodeURIComponent(name).indexOf(filter) == -1 ) + if ( !validTest(name) ) return; synchronize(function() { @@ -87,7 +110,7 @@ function test(name, callback, nowait) { console.error(e); console.warn(callback.toString()); } - _config.Test.push( [ false, "Died on test #" + (_config.Test.length+1) + ": " + e ] ); + _config.Test.push( [ false, "Died on test #" + (_config.Test.length+1) + ": " + e.message ] ); } }); synchronize(function() { @@ -162,6 +185,8 @@ function expect(asserts) { */ function reset() { $("#main").html( _config.fixture ); + $.event.global = {}; + $.ajaxSettings = $.extend({}, _config.ajaxSettings); } /** @@ -224,7 +249,7 @@ function serialArray( a ) { r.push( str ); } - return "[ " + r.join(", ") + " ]" + return "[ " + r.join(", ") + " ]"; } /** @@ -273,8 +298,8 @@ function url(value) { * * @example equals( "Expected 2 characters.", v.formatMessage("Expected {0} characters.", 2) ); * - * @param Object expected * @param Object actual + * @param Object expected * @param String message (optional) */ function equals(actual, expected, message) {