Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ module.exports = function( grunt ) {
"qunit/qunit.css": "qunitjs/qunit/qunit.css",
"qunit/LICENSE.txt": "qunitjs/LICENSE.txt",

"qunit-assert-step/qunit-assert-step.js":
"qunit-assert-step/qunit-assert-step.js",
"qunit-assert-step/MIT-LICENSE.txt":
"qunit-assert-step/MIT-LICENSE.txt",

"requirejs/require.js": "requirejs/require.js",

"sinon/fake_timers.js": "sinon/lib/sinon/util/fake_timers.js",
Expand Down
21 changes: 21 additions & 0 deletions external/qunit-assert-step/MIT-LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Copyright jQuery Foundation and other contributors
http://jquery.com/

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 changes: 26 additions & 0 deletions external/qunit-assert-step/qunit-assert-step.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
QUnit.extend( QUnit.assert, {

/**
* Check the sequence/order
*
* @example test('Example unit test', function(assert) { assert.step(1); setTimeout(function () { assert.step(3); start(); }, 100); assert.step(2); stop(); });
* @param Number expected The excepted step within the test()
* @param String message (optional)
*/
step: function (expected, message) {
// increment internal step counter.
QUnit.config.current.step++;
if (typeof message === "undefined") {
message = "step " + expected;
}
var actual = QUnit.config.current.step;
QUnit.push(QUnit.equiv(actual, expected), actual, expected, message);
}
});

/**
* Reset the step counter for every test()
*/
QUnit.testStart(function () {
QUnit.config.current.step = 0;
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"promises-aplus-tests": "2.1.0",
"q": "1.1.2",
"qunitjs": "1.17.1",
"qunit-assert-step": "1.0.3",
"requirejs": "2.1.17",
"sinon": "1.10.3",
"sizzle": "2.2.0",
Expand Down
1 change: 1 addition & 0 deletions src/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ function Animation( elem, properties, options ) {

// Resolve when we played the last frame; otherwise, reject
if ( gotoEnd ) {
deferred.notifyWith( elem, [ animation, 1, 0 ] );
deferred.resolveWith( elem, [ animation, gotoEnd ] );
} else {
deferred.rejectWith( elem, [ animation, gotoEnd ] );
Expand Down
1 change: 1 addition & 0 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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/npo/npo.js"></script>
<script src="../external/requirejs/require.js"></script>
<script src="../external/sinon/fake_timers.js"></script>
Expand Down
45 changes: 42 additions & 3 deletions test/unit/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -1783,8 +1783,9 @@ test( "non-px animation handles non-numeric start (#11971)", 2, function() {
this.clock.tick( 10 );
});

test("Animation callbacks (#11797)", 15, function() {
var targets = jQuery("#foo").children(),
test("Animation callbacks (#11797)", 16, function() {
var prog = 0,
targets = jQuery("#foo").children(),
done = false,
expectedProgress = 0;

Expand All @@ -1794,7 +1795,8 @@ test("Animation callbacks (#11797)", 15, function() {
ok( true, "empty: start" );
},
progress: function( anim, percent ) {
equal( percent, 0, "empty: progress 0" );
equal( percent, prog, "empty: progress " + prog );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I change something here, because in jQuery if there is no property to animate (here it's empty with the {}) .stop( true ) is called. So, progress is now called twice.

prog = 1;
},
done: function() {
ok( true, "empty: done" );
Expand Down Expand Up @@ -1864,6 +1866,43 @@ test("Animation callbacks (#11797)", 15, function() {
this.clock.tick( 10 );
});

test( "Animation callbacks in order (#2292)", 9, function( assert ) {
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 );
strictEqual( p, 0, "first progress callback: progress ratio" );
strictEqual( ms, dur, "first progress callback: remaining ms" );
} else {
assert.step( 3 );
strictEqual( p, 1, "last progress callback: progress ratio" );
strictEqual( ms, 0, "last progress callback: remaining ms" );
}
},
done: function() {
assert.step( 4 );
},
fail: function() {
ok( false, "Animation failed" );
},
always: function() {
assert.step( 5 );
}
}).finish();

this.clock.tick( dur + 10 );
});

test( "Animate properly sets overflow hidden when animating width/height (#12117)", 8, function() {
jQuery.each( [ "height", "width" ], function( _, prop ) {
jQuery.each( [ 100, 0 ], function( _, value ) {
Expand Down