Skip to content
Permalink
Browse files

Tests: Modified testsuites.js into a subsuiteRunner extension for QUnit.

  • Loading branch information...
Wesley Walser authored and scottgonzalez committed Aug 2, 2011
1 parent 70687f7 commit 8fe87e288544204925265a4e7f19b7dfa24deed6
Showing with 98 additions and 79 deletions.
  1. +6 −2 external/qunit.js
  2. +2 −1 tests/unit/all.html
  3. +8 −0 tests/unit/subsuiteRunner.css
  4. +82 −0 tests/unit/subsuiteRunner.js
  5. +0 −76 tests/unit/testsuites.js
@@ -625,7 +625,7 @@ extend(QUnit, {
var source = sourceFromStacktrace();
if (source) {
details.source = source;
output += '<tr class="test-source"><th>Source: </th><td><pre>' + source +'</pre></td></tr>';
output += '<tr class="test-source"><th>Source: </th><td><pre>' + escapeHtml(source) + '</pre></td></tr>';
}
}
output += "</table>";
@@ -649,6 +649,10 @@ extend(QUnit, {
return window.location.pathname + querystring.slice( 0, -1 );
},

extend: extend,
id: id,
addEvent: addEvent,

// Logging callbacks; all receive a single argument with the listed properties
// run test/logs.html for any related changes
begin: function() {},
@@ -779,7 +783,7 @@ function done() {
}

if ( typeof document !== "undefined" && document.title ) {
// show ✖ for good, ✔ for bad suite result in title
// show ✖ for bad, ✔ for good suite result in title
// use escape sequences in case file gets loaded with non-utf-8-charset
document.title = (config.stats.bad ? "\u2716" : "\u2714") + " " + document.title;
}
@@ -7,8 +7,9 @@
<script src="../../jquery-1.6.2.js"></script>

<link rel="stylesheet" href="../../external/qunit.css">
<link rel="stylesheet" href="subsuiteRunner.css">
<script src="../../external/qunit.js"></script>
<script src="testsuites.js"></script>
<script src="subsuiteRunner.js"></script>

<script>
(function() {
@@ -0,0 +1,8 @@
iframe.qunit-subsuite {
margin: 0;
padding: 0;
border-width: 1px 0 0;
height: 600px;
width: 100%;
background: #fff;
}
@@ -0,0 +1,82 @@
(function( QUnit ) {

var subsuiteFrame;

QUnit.extend( QUnit, {
testSuites: function( suites ) {
for ( var i = 0; i < suites.length; i++ ) {
(function( suite ) {
asyncTest( suite, function() {
QUnit.runSuite( suite );
});
}( suites[i] ) );
}
QUnit.done = function() {
subsuiteFrame.style.display = "none";
};
},

testStart: function( data ) {
// update the test status to show which test suite is running
QUnit.id( "qunit-testresult" ).innerHTML = "Running " + data.name + "...<br>&nbsp;";
},

testDone: function() {
var current = QUnit.id( this.config.current.id ),
children = current.children;

// undo the auto-expansion of failed tests
for ( var i = 0; i < children.length; i++ ) {
if ( children[i].nodeName === "OL" ) {
children[i].style.display = "none";
}
}
},

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;

QUnit.extend( iframeWin.QUnit, {
moduleStart: function( data ) {
// capture module name for messages
module = data.name;
},

testStart: function( data ) {
// capture test name for messages
test = data.name;
},

log: function( data ) {
// pass all test details through to the main page
var message = module + ": " + test + ": " + data.message;
expect( ++count );
QUnit.push( data.result, data.actual, data.expected, message );
},

done: function() {
// 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 ) );

This file was deleted.

0 comments on commit 8fe87e2

Please sign in to comment.
You can’t perform that action at this time.