+jQuery.noConflict(); // Allow the test to run with other libs or jQuery's.
+
var _config = {
fixture: null,
Test: [],
asyncTimeout: 2 // seconds for async timeout
};
+_config.filters = location.search.length > 1 && //restrict modules/tests by get parameters
+ jQuery.map( location.search.slice(1).split('&'), decodeURIComponent );
+
var isLocal = !!(window.location.protocol == 'file:');
-$(function() {
- $('#userAgent').html(navigator.userAgent);
+jQuery(function() {
+ jQuery('#userAgent').html(navigator.userAgent);
runTest();
});
}, 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 = jQuery.ajaxSettings;
synchronize(function() {
time = new Date() - time;
- $("<div>").html(['<p class="result">Tests completed in ',
+ jQuery("<div>").html(['<p class="result">Tests completed in ',
time, ' milliseconds.<br/>',
_config.stats.bad, ' tests of ', _config.stats.all, ' failed.</p>']
.join(''))
.appendTo("body");
- $("#banner").addClass(_config.stats.bad ? "fail" : "pass");
+ jQuery("#banner").addClass(_config.stats.bad ? "fail" : "pass");
});
}
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() {
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() {
else
n.style.display = "none";
};
- $(b).dblclick(function(event) {
+ jQuery(b).dblclick(function(event) {
var target = jQuery(event.target).filter("strong").clone();
if ( target.length ) {
target.children().remove();
- location.href = location.href.match(/^(.+?)(\?.*)?$/)[1] + "?" + encodeURIComponent($.trim(target.text()));
+ location.href = location.href.match(/^(.+?)(\?.*)?$/)[1] + "?" + encodeURIComponent(jQuery.trim(target.text()));
}
});
li.appendChild( b );
* Resets the test setup. Useful for tests that modify the DOM.
*/
function reset() {
- document.getElementById('main').innerHTML = _config.fixture;
+ jQuery("#main").html( _config.fixture );
+ jQuery.event.global = {};
+ jQuery.ajaxSettings = jQuery.extend({}, _config.ajaxSettings);
}
/**
* Asserts true.
- * @example ok( $("a").size() > 5, "There must be at least 5 anchors" );
+ * @example ok( jQuery("a").size() > 5, "There must be at least 5 anchors" );
*/
function ok(a, msg) {
_config.Test.push( [ !!a, msg ] );
r.push( str );
}
- return "[ " + r.join(", ") + " ]"
+ return "[ " + r.join(", ") + " ]";
}
/**
*
* @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) {