aboutsummaryrefslogtreecommitdiffstats
path: root/external/qunit-composite/qunit-composite.js
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2023-03-29 00:29:28 +0200
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2023-05-10 10:53:57 +0200
commitf68d655aff81273d431d5e58bc8af775fc9bd231 (patch)
treef03cdd7c6363c3850dcc1588c65d08fe7e2b95ea /external/qunit-composite/qunit-composite.js
parent43ed5c94aa796767d635ede2f3e4750c8710f47e (diff)
downloadjquery-ui-f68d655aff81273d431d5e58bc8af775fc9bd231.tar.gz
jquery-ui-f68d655aff81273d431d5e58bc8af775fc9bd231.zip
Build: Update dependencies, including QUnit 1 -> 2
Also, fix htmllint lang exclusion patterns. Ref gh-2157
Diffstat (limited to 'external/qunit-composite/qunit-composite.js')
-rw-r--r--external/qunit-composite/qunit-composite.js67
1 files changed, 50 insertions, 17 deletions
diff --git a/external/qunit-composite/qunit-composite.js b/external/qunit-composite/qunit-composite.js
index 1ffd2eea5..8e4fda45a 100644
--- a/external/qunit-composite/qunit-composite.js
+++ b/external/qunit-composite/qunit-composite.js
@@ -1,5 +1,5 @@
/**
- * QUnit Composite v1.0.5-pre
+ * QUnit Composite
*
* https://github.com/JamesMGreene/qunit-composite
*
@@ -14,7 +14,7 @@
factory( QUnit );
}
}(function( QUnit ) {
-var iframe, hasBound,
+var iframe, hasBound, resumeTests, suiteAssert,
modules = 1,
executingComposite = false;
@@ -48,7 +48,9 @@ function runSuite( suite ) {
path = suite;
}
- QUnit.asyncTest( suite, function() {
+ QUnit.test( suite, function( assert ) {
+ resumeTests = assert.async();
+ suiteAssert = assert;
iframe.setAttribute( "src", path );
// QUnit.start is called from the child iframe's QUnit.done hook.
});
@@ -90,12 +92,14 @@ function initIframe() {
}
// 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 );
+ suiteAssert.expect( ++count );
+ suiteAssert.push( data.result, data.actual, data.expected, message );
});
// Continue the outer test when the iframe's test is done
- iframeWin.QUnit.done( QUnit.start );
+ iframeWin.QUnit.done(function() {
+ resumeTests();
+ });
}
iframe = document.createElement( "iframe" );
@@ -107,6 +111,41 @@ function initIframe() {
iframeWin = iframe.contentWindow;
}
+function appendSuitesToHeader( suites ) {
+ var i, suitesLen, suite, path, name, suitesEl, testResultEl,
+ newSuiteListItemEl, newSuiteLinkEl;
+
+ suitesEl = document.getElementById("qunit-testsuites");
+
+ if (!suitesEl) {
+ testResultEl = document.getElementById("qunit-testresult");
+
+ if (!testResultEl) {
+ // QUnit has not been set up yet. Defer until QUnit is ready.
+ QUnit.begin(function () {
+ appendSuitesToHeader(suites);
+ });
+ return;
+ }
+
+ suitesEl = document.createElement("ul");
+ suitesEl.id = "qunit-testsuites";
+ testResultEl.parentNode.insertBefore(suitesEl, testResultEl);
+ }
+
+ for (i = 0, suitesLen = suites.length; i < suitesLen; ++i) {
+ suite = suites[i];
+ newSuiteLinkEl = document.createElement("a");
+ newSuiteLinkEl.innerHTML = suite.name || suite;
+ newSuiteLinkEl.href = suite.path || suite;
+
+ newSuiteListItemEl = document.createElement("li");
+ newSuiteListItemEl.appendChild(newSuiteLinkEl);
+
+ suitesEl.appendChild(newSuiteListItemEl);
+ }
+}
+
/**
* @param {string} [name] Module name to group these test suites.
* @param {Array} suites List of suites where each suite
@@ -122,6 +161,8 @@ QUnit.testSuites = function( name, suites ) {
}
suitesLen = suites.length;
+ appendSuitesToHeader(suites);
+
if ( !hasBound ) {
hasBound = true;
QUnit.begin( initIframe );
@@ -138,7 +179,7 @@ QUnit.testSuites = function( name, suites ) {
}
QUnit.module( name, {
- setup: function () {
+ beforeEach: function () {
executingComposite = true;
}
});
@@ -154,16 +195,8 @@ QUnit.testDone(function( data ) {
}
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 ),
+ testId = data.testId,
+ current = document.getElementById( "qunit-test-output-" + testId ),
children = current && current.children,
src = iframe.src;