[MediaWiki-commits] [Gerrit] data-values/value-view[master]: Simplify QUnit assertions a little

2017-10-09 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/383117 )

Change subject: Simplify QUnit assertions a little
..


Simplify QUnit assertions a little

Bug: T177764
Change-Id: I4159ecda6995f430b3dbdbb2593a9b3bb247aab6
---
M tests/lib/jquery.ui/jquery.ui.inputextender.tests.js
M tests/lib/jquery/jquery.animateWithEvent.tests.js
M tests/src/jquery.valueview.valueview.tests.js
3 files changed, 10 insertions(+), 36 deletions(-)

Approvals:
  Lucas Werkmeister (WMDE): Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/lib/jquery.ui/jquery.ui.inputextender.tests.js 
b/tests/lib/jquery.ui/jquery.ui.inputextender.tests.js
index 0970ef0..4bdd11f 100644
--- a/tests/lib/jquery.ui/jquery.ui.inputextender.tests.js
+++ b/tests/lib/jquery.ui/jquery.ui.inputextender.tests.js
@@ -77,9 +77,7 @@
.fail( function() {
deferred.reject();
} )
-   .always( function() {
-   done(); // *1*
-   } );
+   .always( done );
} );
( callbacks.afterCallingShowExtension || $.noop )( instance );
 
diff --git a/tests/lib/jquery/jquery.animateWithEvent.tests.js 
b/tests/lib/jquery/jquery.animateWithEvent.tests.js
index d214b94..ec4d332 100644
--- a/tests/lib/jquery/jquery.animateWithEvent.tests.js
+++ b/tests/lib/jquery/jquery.animateWithEvent.tests.js
@@ -47,10 +47,9 @@
 
QUnit.test( 'special start callback', function( assert ) {
assert.expect( 2 );
-   var done = assert.async();
var $elem = $( '' );
 
-   $elem.animateWithEvent(
+   return $elem.animateWithEvent(
'foopurpose',
{ width: 200 },
{},
@@ -65,18 +64,15 @@
);
 
}
-   ).promise().done( function() {
-   done();
-   } );
+   );
} );
 
QUnit.test( 'options.start callback', function( assert ) {
assert.expect( 2 );
var $elem = $( '' );
-   var done = assert.async();
var animationEventsAnimation;
 
-   $elem.animateWithEvent(
+   return $elem.animateWithEvent(
'foopurpose',
{ width: 200 },
{
@@ -96,9 +92,7 @@
}, function( animationEvent ) {
animationEventsAnimation = 
animationEvent.animation;
}
-   ).promise().done( function() {
-   done();
-   } );
+   );
} );
 
QUnit.test( 'On jQuery set of multiple elements', function( assert ) {
@@ -119,9 +113,7 @@
if ( $confirmedElems.length >= $elems.length ) {
done();
}
-   } ).promise().done( function() {
-   done();
-   } );
+   } ).promise().done( done );
 
assert.ok(
$elems.length === $confirmedElems.length
diff --git a/tests/src/jquery.valueview.valueview.tests.js 
b/tests/src/jquery.valueview.valueview.tests.js
index 31bc393..2974e50 100644
--- a/tests/src/jquery.valueview.valueview.tests.js
+++ b/tests/src/jquery.valueview.valueview.tests.js
@@ -125,7 +125,6 @@
 
QUnit.test( 'getFormattedValue with DOM', function( assert ) {
assert.expect( 4 );
-   var done = assert.async();
var vvArgs = $.extend( {
value: stringValue
}, initVv.defaultOpts.vvArgs );
@@ -139,7 +138,7 @@
vvArgs: vvArgs
} );
 
-   vvInst.draw()
+   return vvInst.draw()
.done( function() {
assert.equal( vvInst.getFormattedValue(), 'FORMATTED 
VALUE' );
sinon.assert.notCalled( vvArgs.htmlFormatter.format );
@@ -149,19 +148,11 @@
vvArgs.htmlFormatter.format.restore();
vvArgs.plaintextFormatter.format.restore();
vvArgs.parserStore.getParser.restore();
-   } )
-   .fail( function() {
-   assert.ok(
-   false,
-   'draw() returned rejected promise.'
-   );
-   } )
-   .always( done );
+   } );
} );
 
QUnit.test( 'getFormattedValue without DOM', function( assert ) {
assert.expect( 4 );
-   var done = assert.async();

[MediaWiki-commits] [Gerrit] data-values/value-view[master]: Simplify QUnit assertions a little

2017-10-09 Thread WMDE
Thiemo Mättig (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/383117 )

Change subject: Simplify QUnit assertions a little
..

Simplify QUnit assertions a little

Bug: T170515
Change-Id: I4159ecda6995f430b3dbdbb2593a9b3bb247aab6
---
M tests/lib/jquery.ui/jquery.ui.inputextender.tests.js
M tests/lib/jquery/jquery.animateWithEvent.tests.js
M tests/src/jquery.valueview.valueview.tests.js
3 files changed, 10 insertions(+), 36 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/data-values/value-view 
refs/changes/17/383117/1

diff --git a/tests/lib/jquery.ui/jquery.ui.inputextender.tests.js 
b/tests/lib/jquery.ui/jquery.ui.inputextender.tests.js
index 0970ef0..4bdd11f 100644
--- a/tests/lib/jquery.ui/jquery.ui.inputextender.tests.js
+++ b/tests/lib/jquery.ui/jquery.ui.inputextender.tests.js
@@ -77,9 +77,7 @@
.fail( function() {
deferred.reject();
} )
-   .always( function() {
-   done(); // *1*
-   } );
+   .always( done );
} );
( callbacks.afterCallingShowExtension || $.noop )( instance );
 
diff --git a/tests/lib/jquery/jquery.animateWithEvent.tests.js 
b/tests/lib/jquery/jquery.animateWithEvent.tests.js
index d214b94..ec4d332 100644
--- a/tests/lib/jquery/jquery.animateWithEvent.tests.js
+++ b/tests/lib/jquery/jquery.animateWithEvent.tests.js
@@ -47,10 +47,9 @@
 
QUnit.test( 'special start callback', function( assert ) {
assert.expect( 2 );
-   var done = assert.async();
var $elem = $( '' );
 
-   $elem.animateWithEvent(
+   return $elem.animateWithEvent(
'foopurpose',
{ width: 200 },
{},
@@ -65,18 +64,15 @@
);
 
}
-   ).promise().done( function() {
-   done();
-   } );
+   );
} );
 
QUnit.test( 'options.start callback', function( assert ) {
assert.expect( 2 );
var $elem = $( '' );
-   var done = assert.async();
var animationEventsAnimation;
 
-   $elem.animateWithEvent(
+   return $elem.animateWithEvent(
'foopurpose',
{ width: 200 },
{
@@ -96,9 +92,7 @@
}, function( animationEvent ) {
animationEventsAnimation = 
animationEvent.animation;
}
-   ).promise().done( function() {
-   done();
-   } );
+   );
} );
 
QUnit.test( 'On jQuery set of multiple elements', function( assert ) {
@@ -119,9 +113,7 @@
if ( $confirmedElems.length >= $elems.length ) {
done();
}
-   } ).promise().done( function() {
-   done();
-   } );
+   } ).promise().done( done );
 
assert.ok(
$elems.length === $confirmedElems.length
diff --git a/tests/src/jquery.valueview.valueview.tests.js 
b/tests/src/jquery.valueview.valueview.tests.js
index 31bc393..2974e50 100644
--- a/tests/src/jquery.valueview.valueview.tests.js
+++ b/tests/src/jquery.valueview.valueview.tests.js
@@ -125,7 +125,6 @@
 
QUnit.test( 'getFormattedValue with DOM', function( assert ) {
assert.expect( 4 );
-   var done = assert.async();
var vvArgs = $.extend( {
value: stringValue
}, initVv.defaultOpts.vvArgs );
@@ -139,7 +138,7 @@
vvArgs: vvArgs
} );
 
-   vvInst.draw()
+   return vvInst.draw()
.done( function() {
assert.equal( vvInst.getFormattedValue(), 'FORMATTED 
VALUE' );
sinon.assert.notCalled( vvArgs.htmlFormatter.format );
@@ -149,19 +148,11 @@
vvArgs.htmlFormatter.format.restore();
vvArgs.plaintextFormatter.format.restore();
vvArgs.parserStore.getParser.restore();
-   } )
-   .fail( function() {
-   assert.ok(
-   false,
-   'draw() returned rejected promise.'
-   );
-   } )
-   .always( done );
+   } );
} );
 
QUnit.test( 'getFormattedValue without DOM', function( assert ) {
assert.expect( 4 );
-   var done = assert.async();