aboutsummaryrefslogtreecommitdiffstats
path: root/external
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2015-04-06 09:51:10 -0400
committerScott González <scott.gonzalez@gmail.com>2015-04-07 09:03:36 -0400
commit500f6b4992f8a113d7c88f4063b75923fe92663b (patch)
tree8179b72b38ddfcff5c693ec2c613e7e122fa3f84 /external
parentbf03479cc14aa54c2e674cad87bf75c8126cb86f (diff)
downloadjquery-ui-500f6b4992f8a113d7c88f4063b75923fe92663b.tar.gz
jquery-ui-500f6b4992f8a113d7c88f4063b75923fe92663b.zip
Tests: Switch to the new qunit-composite module
This module was created from our existing implementation. Closes gh-1532
Diffstat (limited to 'external')
-rw-r--r--external/qunit-composite/LICENSE.txt36
-rw-r--r--external/qunit-composite/qunit-composite.css13
-rw-r--r--external/qunit-composite/qunit-composite.js184
3 files changed, 233 insertions, 0 deletions
diff --git a/external/qunit-composite/LICENSE.txt b/external/qunit-composite/LICENSE.txt
new file mode 100644
index 000000000..155d8e869
--- /dev/null
+++ b/external/qunit-composite/LICENSE.txt
@@ -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.
diff --git a/external/qunit-composite/qunit-composite.css b/external/qunit-composite/qunit-composite.css
new file mode 100644
index 000000000..54e791b13
--- /dev/null
+++ b/external/qunit-composite/qunit-composite.css
@@ -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;
+}
diff --git a/external/qunit-composite/qunit-composite.js b/external/qunit-composite/qunit-composite.js
new file mode 100644
index 000000000..6cff04b51
--- /dev/null
+++ b/external/qunit-composite/qunit-composite.js
@@ -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 );