aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorThomas Tortorini <thomastortorini@gmail.com>2015-05-11 01:39:26 +0200
committerMichał Gołębiowski <m.goleb@gmail.com>2015-09-08 02:40:54 +0200
commit3dd3d1357d027a487559516fcdd9064cc792edab (patch)
treebd7d71d4cd0cef8c910d73d2bd6562e7660d4b63 /test
parent98cee73244d55910a1ac82bcf6cae04a7f650484 (diff)
downloadjquery-3dd3d1357d027a487559516fcdd9064cc792edab.tar.gz
jquery-3dd3d1357d027a487559516fcdd9064cc792edab.zip
Effects: Finish should call progress
Fixes gh-2283 Closes gh-2292
Diffstat (limited to 'test')
-rw-r--r--test/index.html1
-rw-r--r--test/unit/effects.js49
2 files changed, 46 insertions, 4 deletions
diff --git a/test/index.html b/test/index.html
index 0285176d3..54a1ee041 100644
--- a/test/index.html
+++ b/test/index.html
@@ -13,6 +13,7 @@
<script src="data/jquery-1.9.1.js"></script>
<script src="../external/qunit/qunit.js"></script>
+ <script src="../external/qunit-assert-step/qunit-assert-step.js"></script>
<script src="../external/sinon/sinon-1.14.1.js"></script>
<script src="../external/npo/npo.js"></script>
<script src="../external/requirejs/require.js"></script>
diff --git a/test/unit/effects.js b/test/unit/effects.js
index 755b074f8..4d51adbc9 100644
--- a/test/unit/effects.js
+++ b/test/unit/effects.js
@@ -1832,10 +1832,11 @@ QUnit.test( "non-px animation handles non-numeric start (#11971)", function( ass
this.clock.tick( 10 );
} );
-QUnit.test( "Animation callbacks (#11797)", function( assert ) {
- assert.expect( 15 );
+QUnit.test("Animation callbacks (#11797)", function( assert ) {
+ assert.expect( 16 );
- var targets = jQuery( "#foo" ).children(),
+ var prog = 0,
+ targets = jQuery( "#foo" ).children(),
done = false,
expectedProgress = 0;
@@ -1845,7 +1846,8 @@ QUnit.test( "Animation callbacks (#11797)", function( assert ) {
assert.ok( true, "empty: start" );
},
progress: function( anim, percent ) {
- assert.equal( percent, 0, "empty: progress 0" );
+ assert.equal( percent, prog, "empty: progress " + prog );
+ prog = 1;
},
done: function() {
assert.ok( true, "empty: done" );
@@ -1917,6 +1919,45 @@ QUnit.test( "Animation callbacks (#11797)", function( assert ) {
this.clock.tick( 10 );
} );
+QUnit.test( "Animation callbacks in order (#2292)", function( assert ) {
+ assert.expect( 9 );
+
+ var step = 0,
+ dur = 50;
+
+ // assert? -> github.com/JamesMGreene/qunit-assert-step
+ jQuery( "#foo" ).animate( {
+ width: "5px"
+ }, {
+ duration: dur,
+ start: function() {
+ assert.step( 1 );
+ },
+ progress: function( anim, p, ms ) {
+ if ( !( step++ ) ) {
+ assert.step( 2 );
+ assert.strictEqual( p, 0, "first progress callback: progress ratio" );
+ assert.strictEqual( ms, dur, "first progress callback: remaining ms" );
+ } else {
+ assert.step( 3 );
+ assert.strictEqual( p, 1, "last progress callback: progress ratio" );
+ assert.strictEqual( ms, 0, "last progress callback: remaining ms" );
+ }
+ },
+ done: function() {
+ assert.step( 4 );
+ },
+ fail: function() {
+ assert.ok( false, "Animation failed" );
+ },
+ always: function() {
+ assert.step( 5 );
+ }
+ }).finish();
+
+ this.clock.tick( dur + 10 );
+} );
+
QUnit.test( "Animate properly sets overflow hidden when animating width/height (#12117)", function( assert ) {
assert.expect( 8 );