Tests: Switch to the new qunit-composite module

This module was created from our existing implementation.

Closes gh-1532
This commit is contained in:
Scott González 2015-04-06 09:51:10 -04:00
parent bf03479cc1
commit 500f6b4992
29 changed files with 282 additions and 169 deletions

View File

@ -280,6 +280,10 @@ grunt.initConfig({
"qunit-assert-classes/qunit-assert-classes.js": "qunit-assert-classes/qunit-assert-classes.js",
"qunit-assert-classes/LICENSE.txt": "qunit-assert-classes/LICENSE",
"qunit-composite/qunit-composite.js": "qunit-composite/qunit-composite.js",
"qunit-composite/qunit-composite.css": "qunit-composite/qunit-composite.css",
"qunit-composite/LICENSE.txt": "qunit-composite/LICENSE.txt",
"jquery-mousewheel/jquery.mousewheel.js": "jquery-mousewheel/jquery.mousewheel.js",
"jquery-mousewheel/LICENSE.txt": "jquery-mousewheel/LICENSE.txt",

View File

@ -16,6 +16,7 @@
"jshint": "2.4.4",
"qunit": "1.18.0",
"qunit-assert-classes": "0.1.5",
"qunit-composite": "JamesMGreene/qunit-composite#v1.0.4",
"jquery-1.7.0": "jquery#1.7.0",
"jquery-1.7.1": "jquery#1.7.1",

36
external/qunit-composite/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,36 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/JamesMGreene/qunit-composite
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules directory are externally
maintained libraries used by this software which have their own
licenses; we recommend you read them, as their terms may differ from the
terms above.

View File

@ -0,0 +1,13 @@
.qunit-composite-suite {
position: fixed;
bottom: 0;
left: 0;
margin: 0;
padding: 0;
border-width: 1px 0 0;
height: 45%;
width: 100%;
background: #fff;
}

View File

@ -0,0 +1,184 @@
/**
* QUnit Composite v1.0.4
*
* https://github.com/JamesMGreene/qunit-composite
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license.
* https://jquery.org/license/
*/
(function( QUnit ) {
var iframe, hasBound,
modules = 1,
executingComposite = false;
function hasClass( elem, name ) {
return ( " " + elem.className + " " ).indexOf( " " + name + " " ) > -1;
}
function addClass( elem, name ) {
if ( !hasClass( elem, name ) ) {
elem.className += ( elem.className ? " " : "" ) + name;
}
}
function addEvent( elem, type, fn ) {
if ( elem.addEventListener ) {
// Standards-based browsers
elem.addEventListener( type, fn, false );
} else if ( elem.attachEvent ) {
// support: IE <9
elem.attachEvent( "on" + type, fn );
}
}
function runSuite( suite ) {
var path;
if ( QUnit.is( "object", suite ) ) {
path = suite.path;
suite = suite.name;
} else {
path = suite;
}
QUnit.asyncTest( suite, function() {
iframe.setAttribute( "src", path );
// QUnit.start is called from the child iframe's QUnit.done hook.
});
}
function initIframe() {
var iframeWin,
body = document.body;
function onIframeLoad() {
var moduleName, testName,
count = 0;
if ( !iframe.src ) {
return;
}
iframeWin.QUnit.moduleStart(function( data ) {
// Capture module name for messages
moduleName = data.name;
});
iframeWin.QUnit.testStart(function( data ) {
// Capture test name for messages
testName = data.name;
});
iframeWin.QUnit.testDone(function() {
testName = undefined;
});
iframeWin.QUnit.log(function( data ) {
if (testName === undefined) {
return;
}
// Pass all test details through to the main page
var message = ( moduleName ? moduleName + ": " : "" ) + testName + ": " + ( data.message || ( data.result ? "okay" : "failed" ) );
expect( ++count );
QUnit.push( data.result, data.actual, data.expected, message );
});
// Continue the outer test when the iframe's test is done
iframeWin.QUnit.done( QUnit.start );
}
iframe = document.createElement( "iframe" );
iframe.className = "qunit-composite-suite";
body.appendChild( iframe );
addEvent( iframe, "load", onIframeLoad );
iframeWin = iframe.contentWindow;
}
/**
* @param {string} [name] Module name to group these test suites.
* @param {Array} suites List of suites where each suite
* may either be a string (path to the html test page),
* or an object with a path and name property.
*/
QUnit.testSuites = function( name, suites ) {
var i, suitesLen;
if ( arguments.length === 1 ) {
suites = name;
name = "Composition #" + modules++;
}
suitesLen = suites.length;
if ( !hasBound ) {
hasBound = true;
QUnit.begin( initIframe );
// TODO: Would be better to use something like QUnit.once( 'moduleDone' )
// after the last test suite.
QUnit.moduleDone( function () {
executingComposite = false;
} );
QUnit.done(function() {
iframe.style.display = "none";
});
}
QUnit.module( name, {
setup: function () {
executingComposite = true;
}
});
for ( i = 0; i < suitesLen; i++ ) {
runSuite( suites[ i ] );
}
};
QUnit.testDone(function( data ) {
if ( !executingComposite ) {
return;
}
var i, len,
testId = data.testId || QUnit.config.current.testId || data.testNumber || QUnit.config.current.testNumber,
current = testId ?
(
// QUnit @^1.16.0
document.getElementById( "qunit-test-output-" + testId ) ||
// QUnit @1.15.x
document.getElementById( "qunit-test-output" + testId )
) :
// QUnit @<1.15.0
document.getElementById( QUnit.config.current.id ),
children = current && current.children,
src = iframe.src;
if (!(current && children)) {
return;
}
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 = src;
}
});
// Undo QUnit's auto-expansion for bad tests
for ( i = 0, len = children.length; i < len; i++ ) {
if ( children[ i ].nodeName.toLowerCase() === "ol" ) {
addClass( children[ i ], "qunit-collapsed" );
}
}
// Update Rerun link to point to the standalone test suite page
current.getElementsByTagName( "a" )[ 0 ].href = src;
});
})( QUnit );

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -7,9 +7,9 @@
<script src="../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../external/qunit/qunit.css">
<link rel="stylesheet" href="qunit-composite.css">
<link rel="stylesheet" href="../../external/qunit-composite/qunit-composite.css">
<script src="../../external/qunit/qunit.js"></script>
<script src="qunit-composite.js"></script>
<script src="../../external/qunit-composite/qunit-composite.js"></script>
<script>
(function() {

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -1,13 +0,0 @@
iframe.qunit-subsuite {
position: fixed;
bottom: 0;
left: 0;
margin: 0;
padding: 0;
border-width: 1px 0 0;
height: 45%;
width: 100%;
background: #fff;
}

View File

@ -1,112 +0,0 @@
(function( QUnit ) {
QUnit.extend( QUnit, {
testSuites: function( suites ) {
QUnit.begin(function() {
QUnit.initIframe();
});
for ( var i = 0; i < suites.length; i++ ) {
QUnit.runSuite( suites[i] );
}
QUnit.done(function() {
this.iframe.style.display = "none";
});
},
runSuite: function( suite ) {
var path = suite;
if ( QUnit.is( "object", suite ) ) {
path = suite.path;
suite = suite.name;
}
asyncTest( suite, function() {
QUnit.iframe.setAttribute( "src", path );
});
},
initIframe: function() {
var body = document.body,
iframe = this.iframe = document.createElement( "iframe" ),
iframeWin;
iframe.className = "qunit-subsuite";
body.appendChild( iframe );
function onIframeLoad() {
var module, test,
count = 0;
if (iframe.src === "") {
return;
}
iframeWin.QUnit.moduleStart(function( data ) {
// capture module name for messages
module = data.name;
});
iframeWin.QUnit.testStart(function( data ) {
// capture test name for messages
test = data.name;
});
iframeWin.QUnit.testDone(function() {
test = null;
});
iframeWin.QUnit.log(function( data ) {
if (test === null) {
return;
}
// 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 );
});
iframeWin.QUnit.done(function() {
// start the wrapper test from the main page
start();
});
}
QUnit.addEvent( iframe, "load", onIframeLoad );
iframeWin = iframe.contentWindow;
}
});
QUnit.testStart(function( data ) {
// update the test status to show which test suite is running
QUnit.id( "qunit-testresult" ).innerHTML = "Running " + data.name + "...<br>&nbsp;";
});
QUnit.testDone(function() {
var i,
current = QUnit.id( this.config.current.id ),
children = current.children,
src = this.iframe.src;
// undo the auto-expansion of failed tests
for ( i = 0; i < children.length; i++ ) {
if ( children[i].nodeName === "OL" ) {
children[i].style.display = "none";
}
}
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 = src;
}
});
current.getElementsByTagName("a")[0].href = src;
});
}( QUnit ) );

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>

View File

@ -7,9 +7,9 @@
<script src="../../../external/jquery/jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<link rel="stylesheet" href="../qunit-composite.css">
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../qunit-composite.js"></script>
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>