jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/368121 )
Change subject: Make tests compatible with QUnit 2
..
Make tests compatible with QUnit 2
* Avoid QUnit.asyncTest, QUnit.start/stop (deprecated in 1.x, removed in 2.0).
Instead, use assert.async(), or return a Promise to QUnit.test().
* Remove testCount from QUnit.test(). This has not been required in
QUnit for a while. MW's testrunner has also removed enforcement.
QUnit's improve async control and context-aware assert tracking has
been it mostly redundant. For now, keep it in most places by using
assert.expect(), and remove it from simple cases.
Bug: T170515
Change-Id: I15fc0b75832308cf7865e79b8156432717063631
---
M tests/lib/jquery.event/jquery.event.special.eachchange.tests.js
M tests/lib/jquery.ui/jquery.ui.inputextender.tests.js
M tests/lib/jquery.ui/jquery.ui.listrotator.tests.js
M tests/lib/jquery.ui/jquery.ui.ooMenu.tests.js
M tests/lib/jquery.ui/jquery.ui.preview.tests.js
M tests/lib/jquery.ui/jquery.ui.suggester.tests.js
M tests/lib/jquery.ui/jquery.ui.toggler.tests.js
M tests/lib/jquery/jquery.PurposedCallbacks.tests.js
M tests/lib/jquery/jquery.animateWithEvent.tests.js
M tests/src/ExpertExtender/ExpertExtender.Listrotator.tests.js
M tests/src/ExpertExtender/ExpertExtender.tests.js
M tests/src/experts/GlobeCoordinateInput.tests.js
M tests/src/jquery.valueview.valueview.tests.js
13 files changed, 80 insertions(+), 125 deletions(-)
Approvals:
Jonas Kress (WMDE): Looks good to me, approved
Ladsgroup: Looks good to me, but someone else must approve
jenkins-bot: Verified
Jforrester: Looks good to me, but someone else must approve
diff --git a/tests/lib/jquery.event/jquery.event.special.eachchange.tests.js
b/tests/lib/jquery.event/jquery.event.special.eachchange.tests.js
index 4a22e10..d8c2875 100644
--- a/tests/lib/jquery.event/jquery.event.special.eachchange.tests.js
+++ b/tests/lib/jquery.event/jquery.event.special.eachchange.tests.js
@@ -79,7 +79,8 @@
}
);
- QUnit.test( 'Triggering on a single input element', 2, function( assert
) {
+ QUnit.test( 'Triggering on a single input element', function( assert ) {
+ assert.expect( 2 );
var $subject = generateInputElement( { value: 'a' } );
$subject.on( 'eachchange', iIncr );
@@ -185,7 +186,7 @@
);
} );
- QUnit.test( 'Bubbling up the DOM tree', 1, function( assert ) {
+ QUnit.test( 'Bubbling up the DOM tree', function( assert ) {
var $subject = generateInputElement(),
$parent = $( '' );
@@ -218,7 +219,8 @@
}
);
- QUnit.test( 'Setting prevVal', 4, function( assert ) {
+ QUnit.test( 'Setting prevVal', function( assert ) {
+ assert.expect( 4 );
var $subject = generateInputElement();
var expectedPrevVal = 'a';
diff --git a/tests/lib/jquery.ui/jquery.ui.inputextender.tests.js
b/tests/lib/jquery.ui/jquery.ui.inputextender.tests.js
index a3dddc2..0970ef0 100644
--- a/tests/lib/jquery.ui/jquery.ui.inputextender.tests.js
+++ b/tests/lib/jquery.ui/jquery.ui.inputextender.tests.js
@@ -38,7 +38,7 @@
* Convenience function for testing behavior before/after/during
showing and hiding extension.
*
* @example
-* showAndHideExtensionAgain( newTestInputextender(), {
+* showAndHideExtensionAgain( assert, newTestInputextender(), {
* afterCallingShowExtension: function( instance ) {},
* whenFullyShown: function() { instance },
* afterCallingHideExtension: function( instance ) {},
@@ -53,8 +53,9 @@
* @return {Object} jQuery.Promise Resolved after final hiding is done.
Can be rejected in case
* a hideControl has been injected and gets rejected.
*/
- function showAndHideExtensionAgain( instance, hideControl, callbacks ) {
+ function showAndHideExtensionAgain( assert, instance, hideControl,
callbacks ) {
var deferred = $.Deferred();
+ var done = assert.async( 2 );
if ( !hideControl.done ) {
callbacks = hideControl;
// We will do the hideExtension() immediately in this
case:
@@ -69,22 +70,18 @@
( callbacks.whenFullyHiddenAgain ||
$.noop )( instance );
deferred.resolve();
- QUnit.start(); // *2*
+ done(); // *2*
} );
( callbacks.afterCallingHideExtension || $.noop
)( instance );
-
- QUnit.stop(); // wait for hideExtension()
callback *2*