Permalink
Browse files

Fix testing of no-ajax custom builds

  • Loading branch information...
1 parent 03a0762 commit 14e1501b89491bad5744af4f2a8d084834f9c295 @gibson042 gibson042 committed Nov 1, 2012
Showing with 28 additions and 14 deletions.
  1. +2 −0 test/data/jquery-1.8.2.ajax_xhr.min.js
  2. +6 −4 test/data/testinit.js
  3. +15 −10 test/data/testrunner.js
  4. +3 −0 test/index.html
  5. +2 −0 test/unit/support.js
Oops, something went wrong.
View
@@ -1,15 +1,17 @@
/*jshint multistr:true */
-var jQuery = this.jQuery || "jQuery", // For testing .noConflict()
- $ = this.$ || "$",
- originaljQuery = jQuery,
- original$ = $,
+var originaljQuery = this.jQuery || "jQuery",
+ original$ = this.$ || "$",
hasPHP = true,
// Disable Ajax tests to reduce network strain
// Re-enabled (at least the variable should be declared)
isLocal = window.location.protocol === "file:",
amdDefined;
+// For testing .noConflict()
+this.jQuery = originaljQuery;
+this.$ = original$;
+
/**
* Set up a mock AMD define function for testing AMD registration.
*/
View
@@ -22,6 +22,7 @@ function testSubproject( label, url, risTests ) {
module( label );
// Duckpunch QUnit
+ // TODO restore parent fixture on teardown to support reordering
module = QUnit.module = function( name ) {
var args = arguments;
@@ -41,7 +42,7 @@ function testSubproject( label, url, risTests ) {
// Find test function and wrap to require subproject fixture
for ( ; i >= 0; i-- ) {
- if ( jQuery.isFunction( args[i] ) ) {
+ if ( originaljQuery.isFunction( args[i] ) ) {
args[i] = requireFixture( args[i] );
break;
}
@@ -52,14 +53,14 @@ function testSubproject( label, url, risTests ) {
// Load tests and fixture from subproject
// Test order matters, so we must be synchronous and throw an error on load failure
- jQuery.ajax( url, {
+ originaljQuery.ajax( url, {
async: false,
dataType: "html",
error: function( jqXHR, status ) {
throw new Error( "Could not load: " + url + " (" + status + ")" );
},
success: function( data, status, jqXHR ) {
- var page = jQuery.parseHTML(
+ var page = originaljQuery.parseHTML(
// replace html/head with dummy elements so they are represented in the DOM
( data || "" ).replace( /<\/?((!DOCTYPE|html|head)\b.*?)>/gi, "[$1]" ),
document,
@@ -69,15 +70,15 @@ function testSubproject( label, url, risTests ) {
if ( !page || !page.length ) {
this.error( jqXHR, "no data" );
}
- page = jQuery( page );
+ page = originaljQuery( page );
// Include subproject tests
page.filter("script[src]").add( page.find("script[src]") ).each(function() {
- var src = jQuery( this ).attr("src"),
+ var src = originaljQuery( this ).attr("src"),
html = "<script src='" + url + src + "'></script>";
if ( risTests.test( src ) ) {
- if ( jQuery.isReady ) {
- jQuery("head").first().append( html );
+ if ( originaljQuery.isReady ) {
+ originaljQuery("head").first().append( html );
} else {
document.write( html );
}
@@ -105,7 +106,7 @@ function testSubproject( label, url, risTests ) {
}
// Replace the current fixture, including content outside of #qunit-fixture
- var oldFixture = jQuery("#qunit-fixture");
+ var oldFixture = originaljQuery("#qunit-fixture");
while ( oldFixture.length && !oldFixture.prevAll("[id^='qunit-']").length ) {
oldFixture = oldFixture.parent();
}
@@ -115,7 +116,7 @@ function testSubproject( label, url, risTests ) {
// WARNING: UNDOCUMENTED INTERFACE
QUnit.config.fixture = fixtureHTML;
QUnit.reset();
- if ( jQuery("#qunit-fixture").html() !== fixtureHTML ) {
+ if ( originaljQuery("#qunit-fixture").html() !== fixtureHTML ) {
ok( false, "Copied subproject fixture" );
return;
}
@@ -285,7 +286,11 @@ function testSubproject( label, url, risTests ) {
// Reset internal jQuery state
jQuery.event.global = {};
- jQuery.ajaxSettings = jQuery.extend( {}, ajaxSettings );
+ if ( ajaxSettings ) {
+ jQuery.ajaxSettings = jQuery.extend( {}, ajaxSettings );
+ } else {
+ delete jQuery.ajaxSettings;
+ }
// Let QUnit reset the fixture
reset.apply( this, arguments );
View
@@ -8,6 +8,9 @@
<link rel="Stylesheet" media="screen" href="data/testsuite.css" />
<!-- Includes -->
+ <!-- Allows us to fetch submodule tests when using a no-ajax build -->
+ <script src="data/jquery-1.8.2.ajax_xhr.min.js"></script>
+
<script src="data/testinit.js"></script>
<script src="qunit/qunit/qunit.js"></script>
View
@@ -257,6 +257,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
for ( var i in expected ) {
if ( jQuery.ajax || i !== "ajax" && i !== "cors" ) {
equal( jQuery.support[i], expected[i], "jQuery.support['" + i + "']: " + jQuery.support[i] + ", expected['" + i + "']: " + expected[i]);
+ } else {
+ ok( true, "no ajax; skipping jQuery.support['" + i + "']" );
}
}
});

0 comments on commit 14e1501

Please sign in to comment.