aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorTimmy Willison <timmywillisn@gmail.com>2015-05-05 11:22:40 -0700
committerTimmy Willison <timmywillisn@gmail.com>2015-05-05 11:26:14 -0700
commitb9b5c23fd74c2d3786739c9e6911c811c56a205e (patch)
treef27bae3870d09775818e36bb6976e86bae1dae28 /test
parentb7f9e62642f4534329bf473861c7737669b1e8c4 (diff)
downloadjquery-b9b5c23fd74c2d3786739c9e6911c811c56a205e.tar.gz
jquery-b9b5c23fd74c2d3786739c9e6911c811c56a205e.zip
Effects: add tests for jQuery.easing._default in Animation and Tween
Ref gh-2219
Diffstat (limited to 'test')
-rw-r--r--test/unit/effects.js105
1 files changed, 80 insertions, 25 deletions
diff --git a/test/unit/effects.js b/test/unit/effects.js
index 27c145974..861762eac 100644
--- a/test/unit/effects.js
+++ b/test/unit/effects.js
@@ -1143,49 +1143,49 @@ test( "interrupt toggle", function() {
});
}, shortDuration );
});
- clock.tick(longDuration);
- //FIXME untangle the set timeouts
+ clock.tick( longDuration );
+
+ // FIXME untangle the set timeouts
});
-test("animate with per-property easing", function(){
+test( "animate with per-property easing", function() {
- expect(5);
+ expect( 5 );
- var data = { a:0, b:0, c:0 },
- _test1_called = false,
- _test2_called = false,
- _default_test_called = false,
+ var data = { a: 0, b: 0, c: 0 },
+ test1Called = false,
+ test2Called = false,
+ defaultTestCalled = false,
props = {
a: [ 100, "_test1" ],
b: [ 100, "_test2" ],
c: 100
};
- jQuery.easing["_test1"] = function(p) {
- _test1_called = true;
+ jQuery.easing._test1 = function( p ) {
+ test1Called = true;
return p;
};
- jQuery.easing["_test2"] = function(p) {
- _test2_called = true;
+ jQuery.easing._test2 = function( p ) {
+ test2Called = true;
return p;
};
- jQuery.easing["_default_test"] = function(p) {
- _default_test_called = true;
+ jQuery.easing._defaultTest = function( p ) {
+ defaultTestCalled = true;
return p;
};
- jQuery(data).animate( props, 400, "_default_test", function(){
-
- ok( _test1_called, "Easing function (_test1) called" );
- ok( _test2_called, "Easing function (_test2) called" );
- ok( _default_test_called, "Easing function (_default) called" );
- equal( props.a[ 1 ], "_test1", "animate does not change original props (per-property easing would be lost)");
- equal( props.b[ 1 ], "_test2", "animate does not change original props (per-property easing would be lost)");
+ jQuery( data ).animate( props, 400, "_defaultTest", function() {
+ ok( test1Called, "Easing function (_test1) called" );
+ ok( test2Called, "Easing function (_test2) called" );
+ ok( defaultTestCalled, "Easing function (_default) called" );
+ equal( props.a[ 1 ], "_test1", "animate does not change original props (per-property easing would be lost)" );
+ equal( props.b[ 1 ], "_test2", "animate does not change original props (per-property easing would be lost)" );
});
- this.clock.tick( 400 );
+ this.clock.tick( 400 );
});
test("animate with CSS shorthand properties", function(){
@@ -2227,16 +2227,18 @@ test( "Animation should go to its end state if document.hidden = true", 1, funct
}
});
-test( "jQuery.easing._default (#2218)", 2, function() {
+test( "jQuery.easing._default (gh-2218)", function() {
+ expect( 2 );
+
jQuery( "#foo" )
- .animate({ width: "5px" }, {
+ .animate( { width: "5px" }, {
duration: 5,
start: function( anim ) {
equal( anim.opts.easing, jQuery.easing._default,
"anim.opts.easing should be equal to jQuery.easing._default when the easing argument is not given" );
}
})
- .animate({ height: "5px" }, {
+ .animate( { height: "5px" }, {
duration: 5,
easing: "linear",
start: function( anim ) {
@@ -2245,7 +2247,60 @@ test( "jQuery.easing._default (#2218)", 2, function() {
}
})
.stop();
+
this.clock.tick( 25 );
});
+test( "jQuery.easing._default in Animation (gh-2218", function() {
+ expect( 3 );
+
+ var animation,
+ defaultEasing = jQuery.easing._default,
+ called = false,
+ testObject = { "width": 100 },
+ testDest = { "width": 200 };
+
+ jQuery.easing.custom = function( p ) {
+ called = true;
+ return p;
+ };
+ jQuery.easing._default = "custom";
+
+ animation = jQuery.Animation( testObject, testDest, { "duration": 1 } );
+ animation.done( function() {
+ equal( testObject.width, testDest.width, "Animated width" );
+ ok( called, "Custom jQuery.easing._default called" );
+ strictEqual( animation.opts.easing, "custom",
+ "Animation used custom jQuery.easing._default" );
+ jQuery.easing._default = defaultEasing;
+ delete jQuery.easing.custom;
+ });
+
+ this.clock.tick( 10 );
+});
+
+test( "jQuery.easing._default in Tween (gh-2218)", function() {
+ expect( 3 );
+
+ var tween,
+ defaultEasing = jQuery.easing._default,
+ called = false,
+ testObject = { "width": 100 };
+
+ jQuery.easing.custom = function( p ) {
+ called = true;
+ return p;
+ };
+ jQuery.easing._default = "custom";
+
+ tween = jQuery.Tween( testObject, { "duration": 1 }, "width", 200 );
+ tween.run( 1 );
+ equal( testObject.width, 200, "Animated width" );
+ ok( called, "Custom jQuery.easing._default called" );
+ strictEqual( tween.easing, "custom",
+ "Animation used custom jQuery.easing._default" );
+ jQuery.easing._default = defaultEasing;
+ delete jQuery.easing.custom;
+});
+
})();