diff options
Diffstat (limited to 'test/data/testrunner.js')
-rw-r--r-- | test/data/testrunner.js | 136 |
1 files changed, 0 insertions, 136 deletions
diff --git a/test/data/testrunner.js b/test/data/testrunner.js index aea91624e..0f741fa9d 100644 --- a/test/data/testrunner.js +++ b/test/data/testrunner.js @@ -186,8 +186,6 @@ reset = function() { // Cleanup globals Globals.cleanup(); - - jQuery("#qunit-fixture")[0].innerHTML = QUnit.config.fixture; }; QUnit.testDone(reset); @@ -214,138 +212,4 @@ window.Globals = (function() { }; })(); -/** - * Test a subproject with its own fixture - * @param {String} label Project name - * @param {String} url Test folder location - * @param {RegExp} risTests To filter script sources - */ -function testSubproject( label, subProjectURL, risTests, complete ) { - var sub, fixture, fixtureHTML, - fixtureReplaced = false; - - // Don't let subproject tests jump the gun - QUnit.config.reorder = false; - - // Create module - module( label ); - - // Duckpunch QUnit - // TODO restore parent fixture on teardown to support reordering - module = QUnit.module = function( name ) { - var args = arguments; - - // Remember subproject-scoped module name - sub = name; - - // Override - args[0] = label; - return qunitModule.apply( this, args ); - }; - test = function( name ) { - var args = arguments, - i = args.length - 1; - - // Prepend subproject-scoped module name to test name - args[0] = sub + ": " + name; - - // Find test function and wrap to require subproject fixture - for ( ; i >= 0; i-- ) { - if ( supportjQuery.isFunction( args[i] ) ) { - args[i] = requireFixture( args[i] ); - break; - } - } - - return qunitTest.apply( this, args ); - }; - - // Load tests and fixture from subproject - // Test order matters, so we must be synchronous and throw an error on load failure - supportjQuery.ajax( subProjectURL, { - async: false, - dataType: "html", - error: function( jqXHR, status ) { - throw new Error( "Could not load: " + subProjectURL + " (" + status + ")" ); - }, - success: function( data, status, jqXHR ) { - var sources = [], - page = supportjQuery.parseHTML( - // replace html/head with dummy elements so they are represented in the DOM - ( data || "" ).replace( /<\/?((!DOCTYPE|html|head)\b.*?)>/gi, "[$1]" ), - document, - true - ); - - if ( !page || !page.length ) { - this.error( jqXHR, "no data" ); - } - page = supportjQuery( page ); - - // Include subproject tests - page.filter("script[src]").add( page.find("script[src]") ).map(function() { - var src = supportjQuery( this ).attr("src"); - if ( risTests.test( src ) ) { - sources.push( src ); - } - }); - - // Ensure load order - (function loadDep() { - var dep = sources.shift(); - if ( dep ) { - require( [ subProjectURL + dep ], loadDep ); - } else if ( complete ) { - complete(); - } - })(); - - // Get the fixture, including content outside of #qunit-fixture - fixture = page.find("[id='qunit-fixture']"); - fixtureHTML = fixture.html(); - fixture.empty(); - while ( fixture.length && !fixture.prevAll("[id='qunit']").length ) { - fixture = fixture.parent(); - } - fixture = fixture.add( fixture.nextAll() ); - } - }); - - function requireFixture( fn ) { - return function() { - if ( !fixtureReplaced ) { - // Make sure that we retrieved a fixture for the subproject - if ( !fixture.length ) { - ok( false, "Found subproject fixture" ); - return; - } - - // Update helper function behavior - baseURL = subProjectURL; - - // Replace the current fixture, including content outside of #qunit-fixture - var oldFixture = supportjQuery("#qunit-fixture"); - while ( oldFixture.length && !oldFixture.prevAll("[id='qunit']").length ) { - oldFixture = oldFixture.parent(); - } - oldFixture.nextAll().remove(); - oldFixture.replaceWith( fixture ); - - // WARNING: UNDOCUMENTED INTERFACE - QUnit.config.fixture = fixtureHTML; - reset(); - if ( supportjQuery("#qunit-fixture").html() !== fixtureHTML ) { - ok( false, "Copied subproject fixture" ); - return; - } - - fixtureReplaced = true; - } - fn.apply( this, arguments ); - }; - } -} - -return testSubproject; - }); |