Skip to content

Commit 500f6b4

Browse files
committed
Tests: Switch to the new qunit-composite module
This module was created from our existing implementation. Closes gh-1532
1 parent bf03479 commit 500f6b4

File tree

29 files changed

+282
-169
lines changed

29 files changed

+282
-169
lines changed

Gruntfile.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,10 @@ grunt.initConfig({
280280
"qunit-assert-classes/qunit-assert-classes.js": "qunit-assert-classes/qunit-assert-classes.js",
281281
"qunit-assert-classes/LICENSE.txt": "qunit-assert-classes/LICENSE",
282282

283+
"qunit-composite/qunit-composite.js": "qunit-composite/qunit-composite.js",
284+
"qunit-composite/qunit-composite.css": "qunit-composite/qunit-composite.css",
285+
"qunit-composite/LICENSE.txt": "qunit-composite/LICENSE.txt",
286+
283287
"jquery-mousewheel/jquery.mousewheel.js": "jquery-mousewheel/jquery.mousewheel.js",
284288
"jquery-mousewheel/LICENSE.txt": "jquery-mousewheel/LICENSE.txt",
285289

bower.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"jshint": "2.4.4",
1717
"qunit": "1.18.0",
1818
"qunit-assert-classes": "0.1.5",
19+
"qunit-composite": "JamesMGreene/qunit-composite#v1.0.4",
1920

2021
"jquery-1.7.0": "jquery#1.7.0",
2122
"jquery-1.7.1": "jquery#1.7.1",

external/qunit-composite/LICENSE.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Copyright jQuery Foundation and other contributors, https://jquery.org/
2+
3+
This software consists of voluntary contributions made by many
4+
individuals. For exact contribution history, see the revision history
5+
available at https://github.com/JamesMGreene/qunit-composite
6+
7+
The following license applies to all parts of this software except as
8+
documented below:
9+
10+
====
11+
12+
Permission is hereby granted, free of charge, to any person obtaining
13+
a copy of this software and associated documentation files (the
14+
"Software"), to deal in the Software without restriction, including
15+
without limitation the rights to use, copy, modify, merge, publish,
16+
distribute, sublicense, and/or sell copies of the Software, and to
17+
permit persons to whom the Software is furnished to do so, subject to
18+
the following conditions:
19+
20+
The above copyright notice and this permission notice shall be
21+
included in all copies or substantial portions of the Software.
22+
23+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30+
31+
====
32+
33+
All files located in the node_modules directory are externally
34+
maintained libraries used by this software which have their own
35+
licenses; we recommend you read them, as their terms may differ from the
36+
terms above.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.qunit-composite-suite {
2+
position: fixed;
3+
bottom: 0;
4+
left: 0;
5+
6+
margin: 0;
7+
padding: 0;
8+
border-width: 1px 0 0;
9+
height: 45%;
10+
width: 100%;
11+
12+
background: #fff;
13+
}
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
/**
2+
* QUnit Composite v1.0.4
3+
*
4+
* https://github.com/JamesMGreene/qunit-composite
5+
*
6+
* Copyright jQuery Foundation and other contributors
7+
* Released under the MIT license.
8+
* https://jquery.org/license/
9+
*/
10+
(function( QUnit ) {
11+
var iframe, hasBound,
12+
modules = 1,
13+
executingComposite = false;
14+
15+
function hasClass( elem, name ) {
16+
return ( " " + elem.className + " " ).indexOf( " " + name + " " ) > -1;
17+
}
18+
19+
function addClass( elem, name ) {
20+
if ( !hasClass( elem, name ) ) {
21+
elem.className += ( elem.className ? " " : "" ) + name;
22+
}
23+
}
24+
25+
function addEvent( elem, type, fn ) {
26+
if ( elem.addEventListener ) {
27+
// Standards-based browsers
28+
elem.addEventListener( type, fn, false );
29+
} else if ( elem.attachEvent ) {
30+
// support: IE <9
31+
elem.attachEvent( "on" + type, fn );
32+
}
33+
}
34+
35+
function runSuite( suite ) {
36+
var path;
37+
38+
if ( QUnit.is( "object", suite ) ) {
39+
path = suite.path;
40+
suite = suite.name;
41+
} else {
42+
path = suite;
43+
}
44+
45+
QUnit.asyncTest( suite, function() {
46+
iframe.setAttribute( "src", path );
47+
// QUnit.start is called from the child iframe's QUnit.done hook.
48+
});
49+
}
50+
51+
function initIframe() {
52+
var iframeWin,
53+
body = document.body;
54+
55+
function onIframeLoad() {
56+
var moduleName, testName,
57+
count = 0;
58+
59+
if ( !iframe.src ) {
60+
return;
61+
}
62+
63+
iframeWin.QUnit.moduleStart(function( data ) {
64+
// Capture module name for messages
65+
moduleName = data.name;
66+
});
67+
68+
iframeWin.QUnit.testStart(function( data ) {
69+
// Capture test name for messages
70+
testName = data.name;
71+
});
72+
iframeWin.QUnit.testDone(function() {
73+
testName = undefined;
74+
});
75+
76+
iframeWin.QUnit.log(function( data ) {
77+
if (testName === undefined) {
78+
return;
79+
}
80+
// Pass all test details through to the main page
81+
var message = ( moduleName ? moduleName + ": " : "" ) + testName + ": " + ( data.message || ( data.result ? "okay" : "failed" ) );
82+
expect( ++count );
83+
QUnit.push( data.result, data.actual, data.expected, message );
84+
});
85+
86+
// Continue the outer test when the iframe's test is done
87+
iframeWin.QUnit.done( QUnit.start );
88+
}
89+
90+
iframe = document.createElement( "iframe" );
91+
iframe.className = "qunit-composite-suite";
92+
body.appendChild( iframe );
93+
94+
addEvent( iframe, "load", onIframeLoad );
95+
96+
iframeWin = iframe.contentWindow;
97+
}
98+
99+
/**
100+
* @param {string} [name] Module name to group these test suites.
101+
* @param {Array} suites List of suites where each suite
102+
* may either be a string (path to the html test page),
103+
* or an object with a path and name property.
104+
*/
105+
QUnit.testSuites = function( name, suites ) {
106+
var i, suitesLen;
107+
108+
if ( arguments.length === 1 ) {
109+
suites = name;
110+
name = "Composition #" + modules++;
111+
}
112+
suitesLen = suites.length;
113+
114+
if ( !hasBound ) {
115+
hasBound = true;
116+
QUnit.begin( initIframe );
117+
118+
// TODO: Would be better to use something like QUnit.once( 'moduleDone' )
119+
// after the last test suite.
120+
QUnit.moduleDone( function () {
121+
executingComposite = false;
122+
} );
123+
124+
QUnit.done(function() {
125+
iframe.style.display = "none";
126+
});
127+
}
128+
129+
QUnit.module( name, {
130+
setup: function () {
131+
executingComposite = true;
132+
}
133+
});
134+
135+
for ( i = 0; i < suitesLen; i++ ) {
136+
runSuite( suites[ i ] );
137+
}
138+
};
139+
140+
QUnit.testDone(function( data ) {
141+
if ( !executingComposite ) {
142+
return;
143+
}
144+
145+
var i, len,
146+
testId = data.testId || QUnit.config.current.testId || data.testNumber || QUnit.config.current.testNumber,
147+
current = testId ?
148+
(
149+
// QUnit @^1.16.0
150+
document.getElementById( "qunit-test-output-" + testId ) ||
151+
// QUnit @1.15.x
152+
document.getElementById( "qunit-test-output" + testId )
153+
) :
154+
// QUnit @<1.15.0
155+
document.getElementById( QUnit.config.current.id ),
156+
children = current && current.children,
157+
src = iframe.src;
158+
159+
if (!(current && children)) {
160+
return;
161+
}
162+
163+
addEvent( current, "dblclick", function( e ) {
164+
var target = e && e.target ? e.target : window.event.srcElement;
165+
if ( target.nodeName.toLowerCase() === "span" || target.nodeName.toLowerCase() === "b" ) {
166+
target = target.parentNode;
167+
}
168+
if ( window.location && target.nodeName.toLowerCase() === "strong" ) {
169+
window.location = src;
170+
}
171+
});
172+
173+
// Undo QUnit's auto-expansion for bad tests
174+
for ( i = 0, len = children.length; i < len; i++ ) {
175+
if ( children[ i ].nodeName.toLowerCase() === "ol" ) {
176+
addClass( children[ i ], "qunit-collapsed" );
177+
}
178+
}
179+
180+
// Update Rerun link to point to the standalone test suite page
181+
current.getElementsByTagName( "a" )[ 0 ].href = src;
182+
});
183+
184+
})( QUnit );

tests/unit/accordion/all.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<script src="../../../external/jquery/jquery.js"></script>
88

99
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
10-
<link rel="stylesheet" href="../qunit-composite.css">
10+
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
1111
<script src="../../../external/qunit/qunit.js"></script>
12-
<script src="../qunit-composite.js"></script>
12+
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
1313
<script src="../subsuite.js"></script>
1414

1515
<script>

tests/unit/all.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<script src="../../external/jquery/jquery.js"></script>
88

99
<link rel="stylesheet" href="../../external/qunit/qunit.css">
10-
<link rel="stylesheet" href="qunit-composite.css">
10+
<link rel="stylesheet" href="../../external/qunit-composite/qunit-composite.css">
1111
<script src="../../external/qunit/qunit.js"></script>
12-
<script src="qunit-composite.js"></script>
12+
<script src="../../external/qunit-composite/qunit-composite.js"></script>
1313

1414
<script>
1515
(function() {

tests/unit/autocomplete/all.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<script src="../../../external/jquery/jquery.js"></script>
88

99
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
10-
<link rel="stylesheet" href="../qunit-composite.css">
10+
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
1111
<script src="../../../external/qunit/qunit.js"></script>
12-
<script src="../qunit-composite.js"></script>
12+
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
1313
<script src="../subsuite.js"></script>
1414

1515
<script>

tests/unit/button/all.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<script src="../../../external/jquery/jquery.js"></script>
88

99
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
10-
<link rel="stylesheet" href="../qunit-composite.css">
10+
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
1111
<script src="../../../external/qunit/qunit.js"></script>
12-
<script src="../qunit-composite.js"></script>
12+
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
1313
<script src="../subsuite.js"></script>
1414

1515
<script>

tests/unit/core/all.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<script src="../../../external/jquery/jquery.js"></script>
88

99
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
10-
<link rel="stylesheet" href="../qunit-composite.css">
10+
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
1111
<script src="../../../external/qunit/qunit.js"></script>
12-
<script src="../qunit-composite.js"></script>
12+
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
1313
<script src="../subsuite.js"></script>
1414

1515
<script>

tests/unit/datepicker/all.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<script src="../../../external/jquery/jquery.js"></script>
88

99
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
10-
<link rel="stylesheet" href="../qunit-composite.css">
10+
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
1111
<script src="../../../external/qunit/qunit.js"></script>
12-
<script src="../qunit-composite.js"></script>
12+
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
1313
<script src="../subsuite.js"></script>
1414

1515
<script>

tests/unit/dialog/all.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<script src="../../../external/jquery/jquery.js"></script>
88

99
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
10-
<link rel="stylesheet" href="../qunit-composite.css">
10+
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
1111
<script src="../../../external/qunit/qunit.js"></script>
12-
<script src="../qunit-composite.js"></script>
12+
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
1313
<script src="../subsuite.js"></script>
1414

1515
<script>

tests/unit/draggable/all.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<script src="../../../external/jquery/jquery.js"></script>
88

99
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
10-
<link rel="stylesheet" href="../qunit-composite.css">
10+
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
1111
<script src="../../../external/qunit/qunit.js"></script>
12-
<script src="../qunit-composite.js"></script>
12+
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
1313
<script src="../subsuite.js"></script>
1414

1515
<script>

tests/unit/droppable/all.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<script src="../../../external/jquery/jquery.js"></script>
88

99
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
10-
<link rel="stylesheet" href="../qunit-composite.css">
10+
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
1111
<script src="../../../external/qunit/qunit.js"></script>
12-
<script src="../qunit-composite.js"></script>
12+
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
1313
<script src="../subsuite.js"></script>
1414

1515
<script>

tests/unit/effects/all.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<script src="../../../external/jquery/jquery.js"></script>
88

99
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
10-
<link rel="stylesheet" href="../qunit-composite.css">
10+
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
1111
<script src="../../../external/qunit/qunit.js"></script>
12-
<script src="../qunit-composite.js"></script>
12+
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
1313
<script src="../subsuite.js"></script>
1414

1515
<script>

tests/unit/menu/all.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<script src="../../../external/jquery/jquery.js"></script>
88

99
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
10-
<link rel="stylesheet" href="../qunit-composite.css">
10+
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
1111
<script src="../../../external/qunit/qunit.js"></script>
12-
<script src="../qunit-composite.js"></script>
12+
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
1313
<script src="../subsuite.js"></script>
1414

1515
<script>

tests/unit/position/all.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<script src="../../../external/jquery/jquery.js"></script>
88

99
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
10-
<link rel="stylesheet" href="../qunit-composite.css">
10+
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
1111
<script src="../../../external/qunit/qunit.js"></script>
12-
<script src="../qunit-composite.js"></script>
12+
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
1313
<script src="../subsuite.js"></script>
1414

1515
<script>

0 commit comments

Comments
 (0)