Effects: Finish should call progress

(cherry-picked from 3dd3d1357d)

Fixes gh-2283
Closes gh-2292
This commit is contained in:
Thomas Tortorini
2015-05-11 01:39:26 +02:00
committed by Michał Gołębiowski
parent dc76dca295
commit f71e32d4b4
7 changed files with 100 additions and 4 deletions

View File

@@ -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/sinon/timers_ie.js"></script>
<script src="../external/npo/npo.js"></script>

49
test/unit/effects.js vendored
View File

@@ -1849,10 +1849,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;
@@ -1862,7 +1863,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" );
@@ -1934,6 +1936,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 );