Last active
December 11, 2015 03:48
-
-
Save JamesMGreene/4540402 to your computer and use it in GitHub Desktop.
Our old proprietary version of the QUnit subsuite (composite) addon.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function( QUnit ) { | |
var subsuiteFrame; | |
QUnit.extend( QUnit, { | |
testSuites: function( suites ) { | |
QUnit.done(function(result) { | |
subsuiteFrame.style.display = "none"; | |
}); | |
for ( var i = 0; i < suites.length; i++ ) { | |
(function( suite ) { | |
asyncTest( suite, function() { | |
QUnit.runSuite( suite ); | |
}); | |
})( suites[i] ); | |
} | |
}, | |
runSuite: function( suite ) { | |
var body = document.getElementsByTagName( "body" )[0], | |
iframe = subsuiteFrame = document.createElement( "iframe" ), | |
iframeWin; | |
iframe.className = "qunit-subsuite"; | |
body.appendChild( iframe ); | |
function onIframeLoad() { | |
var module, | |
test, | |
count = 0; | |
var iFrameQUnit = iframeWin.QUnit; | |
iFrameQUnit.moduleStart(function( data ) { | |
// capture module name for messages | |
module = data.name; | |
}); | |
iFrameQUnit.testStart(function( data ) { | |
// capture test name for messages | |
test = data.name; | |
}); | |
iFrameQUnit.log(function( data ) { | |
// pass all test details through to the main page | |
var message = ( module ? module + ": " : "" ) + test + ": " + ( data.message || ( data.result ? 'okay' : 'failed' )); | |
expect( ++count ); | |
QUnit.push( data.result, data.actual, data.expected, message ); | |
}); | |
iFrameQUnit.done(function( data ) { | |
// start the wrapper test from the main page | |
start(); | |
}); | |
} | |
QUnit.addEvent( iframe, "load", onIframeLoad ); | |
iframeWin = iframe.contentWindow; | |
iframe.setAttribute( "src", suite ); | |
this.runSuite = function( suite ) { | |
iframe.setAttribute( "src", suite ); | |
}; | |
} | |
}); | |
QUnit.testStart(function( data ) { | |
// update the test status to show which test suite is running | |
QUnit.id( "qunit-testresult" ).innerHTML = "Running " + data.name + "...<br/> "; | |
}); | |
QUnit.testDone(function() { | |
var current = QUnit.id( this.config.current.id ), | |
src = this.iframe.src; | |
QUnit.addEvent(current, "dblclick", function( e ) { | |
var target = e && e.target ? e.target : window.event.srcElement; | |
if ( target.nodeName.toLowerCase() === "span" || target.nodeName.toLowerCase() === "b" ) { | |
target = target.parentNode; | |
} | |
if ( window.location && target.nodeName.toLowerCase() === "strong" ) { | |
window.location.href = src; | |
} | |
}); | |
current.getElementsByTagName('a')[0].href = src; | |
}); | |
})( QUnit ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment