Skip to content

Commit

Permalink
test runner: the changes are:
Browse files Browse the repository at this point in the history
- Replaced all the $ for jQuery in the tests and suite.
- Added a noConflict to testrunner.js.
- Modified the test for noConflict() so that it still work.
- Added jQuery 1.2.1 and 1.2.3 to otherlibs.
  • Loading branch information
flesler committed May 28, 2008
1 parent abb055b commit 9e48649
Show file tree
Hide file tree
Showing 11 changed files with 863 additions and 837 deletions.
26 changes: 14 additions & 12 deletions test/data/testrunner.js
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,5 @@
jQuery.noConflict(); // Allow the test to run with other libs or jQuery's.

var _config = { var _config = {
fixture: null, fixture: null,
Test: [], Test: [],
Expand All @@ -14,12 +16,12 @@ var _config = {
}; };


_config.filters = location.search.length > 1 && //restrict modules/tests by get parameters _config.filters = location.search.length > 1 && //restrict modules/tests by get parameters
$.map( location.search.slice(1).split('&'), decodeURIComponent ); jQuery.map( location.search.slice(1).split('&'), decodeURIComponent );


var isLocal = !!(window.location.protocol == 'file:'); var isLocal = !!(window.location.protocol == 'file:');


$(function() { jQuery(function() {
$('#userAgent').html(navigator.userAgent); jQuery('#userAgent').html(navigator.userAgent);
runTest(); runTest();
}); });


Expand Down Expand Up @@ -81,15 +83,15 @@ function runTest() {
_config.blocking = false; _config.blocking = false;
var time = new Date(); var time = new Date();
_config.fixture = document.getElementById('main').innerHTML; _config.fixture = document.getElementById('main').innerHTML;
_config.ajaxSettings = $.ajaxSettings; _config.ajaxSettings = jQuery.ajaxSettings;
synchronize(function() { synchronize(function() {
time = new Date() - time; time = new Date() - time;
$("<div>").html(['<p class="result">Tests completed in ', jQuery("<div>").html(['<p class="result">Tests completed in ',
time, ' milliseconds.<br/>', time, ' milliseconds.<br/>',
_config.stats.bad, ' tests of ', _config.stats.all, ' failed.</p>'] _config.stats.bad, ' tests of ', _config.stats.all, ' failed.</p>']
.join('')) .join(''))
.appendTo("body"); .appendTo("body");
$("#banner").addClass(_config.stats.bad ? "fail" : "pass"); jQuery("#banner").addClass(_config.stats.bad ? "fail" : "pass");
}); });
} }


Expand Down Expand Up @@ -154,11 +156,11 @@ function test(name, callback, nowait) {
else else
n.style.display = "none"; n.style.display = "none";
}; };
$(b).dblclick(function(event) { jQuery(b).dblclick(function(event) {
var target = jQuery(event.target).filter("strong").clone(); var target = jQuery(event.target).filter("strong").clone();
if ( target.length ) { if ( target.length ) {
target.children().remove(); 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 ); li.appendChild( b );
Expand All @@ -184,14 +186,14 @@ function expect(asserts) {
* Resets the test setup. Useful for tests that modify the DOM. * Resets the test setup. Useful for tests that modify the DOM.
*/ */
function reset() { function reset() {
$("#main").html( _config.fixture ); jQuery("#main").html( _config.fixture );
$.event.global = {}; jQuery.event.global = {};
$.ajaxSettings = $.extend({}, _config.ajaxSettings); jQuery.ajaxSettings = jQuery.extend({}, _config.ajaxSettings);
} }


/** /**
* Asserts true. * 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) { function ok(a, msg) {
_config.Test.push( [ !!a, msg ] ); _config.Test.push( [ !!a, msg ] );
Expand Down
7 changes: 6 additions & 1 deletion test/index.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
<title>jQuery Test Suite</title> <title>jQuery Test Suite</title>
<link rel="Stylesheet" media="screen" href="data/testsuite.css" /> <link rel="Stylesheet" media="screen" href="data/testsuite.css" />
<!-- Includes --> <!-- Includes -->
<script type="text/javascript">var jQuery = "jQuery", $ = "$"; // For testing .noConflict()</script> <script type="text/javascript">
var jQuery = this.jQuery || "jQuery", // For testing .noConflict()
$ = this.$ || "$",
originaljQuery = jQuery,
original$ = $;
</script>
<script type="text/javascript" src="../dist/jquery.js"></script> <script type="text/javascript" src="../dist/jquery.js"></script>
<script type="text/javascript" src="data/testrunner.js"></script> <script type="text/javascript" src="data/testrunner.js"></script>
<script type="text/javascript" src="unit/core.js"></script> <script type="text/javascript" src="unit/core.js"></script>
Expand Down
11 changes: 11 additions & 0 deletions test/otherlibs/jquery/1.2.1/jquery.js

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions test/otherlibs/jquery/1.2.3/jquery.js

Large diffs are not rendered by default.

Loading

0 comments on commit 9e48649

Please sign in to comment.