2011-03-29 20:32:48 +00:00
|
|
|
(function($) {
|
|
|
|
|
2011-05-12 15:22:49 +00:00
|
|
|
function present( value, array, message ) {
|
|
|
|
QUnit.push( jQuery.inArray( value, array ) !== -1 , value, array, message );
|
|
|
|
}
|
|
|
|
|
|
|
|
function notPresent( value, array, message ) {
|
|
|
|
QUnit.push( jQuery.inArray( value, array ) === -1 , value, array, message );
|
|
|
|
}
|
|
|
|
|
2011-05-16 22:19:57 +00:00
|
|
|
// minDuration is used for "short" animate tests where we are only concerned about the final
|
|
|
|
var minDuration = 15,
|
|
|
|
|
|
|
|
// duration is used for "long" animates where we plan on testing properties during animation
|
|
|
|
duration = 200,
|
|
|
|
|
|
|
|
// mid is used for testing in the "middle" of the "duration" animations
|
|
|
|
mid = duration / 2;
|
2011-03-29 20:32:48 +00:00
|
|
|
|
2011-05-01 11:23:19 +00:00
|
|
|
module( "effects.core" );
|
|
|
|
|
|
|
|
$.each( $.effects.effect, function( effect ) {
|
|
|
|
if ( effect === "transfer" ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
module( "effect."+effect );
|
2011-05-12 15:22:49 +00:00
|
|
|
asyncTest( "show/hide", function() {
|
2011-05-01 11:23:19 +00:00
|
|
|
var hidden = $( "div.hidden" );
|
2011-05-04 06:54:47 +00:00
|
|
|
expect( 8 );
|
|
|
|
|
|
|
|
var count = 0,
|
|
|
|
test = 0;
|
|
|
|
|
|
|
|
function queueTest( fn ) {
|
|
|
|
count++;
|
|
|
|
var point = count;
|
|
|
|
return function( next ) {
|
|
|
|
test++;
|
2011-05-12 15:22:49 +00:00
|
|
|
equal( point, test, "Queue function fired in order" );
|
2011-05-04 06:54:47 +00:00
|
|
|
if ( fn ) {
|
2011-05-16 22:19:57 +00:00
|
|
|
fn();
|
2011-05-04 06:54:47 +00:00
|
|
|
} else {
|
2011-05-16 22:19:57 +00:00
|
|
|
setTimeout( next, minDuration );
|
2011-05-04 06:54:47 +00:00
|
|
|
}
|
2011-05-12 15:22:49 +00:00
|
|
|
};
|
2011-05-04 06:54:47 +00:00
|
|
|
}
|
2011-05-16 22:19:57 +00:00
|
|
|
|
|
|
|
hidden.queue( queueTest() ).show( effect, minDuration, queueTest(function() {
|
2011-05-01 11:23:19 +00:00
|
|
|
equal( hidden.css("display"), "block", "Hidden is shown after .show(\"" +effect+ "\", time)" );
|
2011-05-16 22:19:57 +00:00
|
|
|
})).queue( queueTest() ).hide( effect, minDuration, queueTest(function() {
|
2011-05-01 11:23:19 +00:00
|
|
|
equal( hidden.css("display"), "none", "Back to hidden after .hide(\"" +effect+ "\", time)" );
|
2011-05-04 06:54:47 +00:00
|
|
|
})).queue( queueTest(function(next) {
|
2011-05-12 15:22:49 +00:00
|
|
|
deepEqual( hidden.queue(), ["inprogress"], "Only the inprogress sentinel remains");
|
2011-05-01 11:23:19 +00:00
|
|
|
start();
|
2011-05-04 06:54:47 +00:00
|
|
|
}));
|
2011-05-01 11:23:19 +00:00
|
|
|
});
|
2011-03-29 20:32:48 +00:00
|
|
|
});
|
|
|
|
|
2011-05-12 15:22:49 +00:00
|
|
|
module("animateClass");
|
|
|
|
|
|
|
|
asyncTest( "animateClass works with borderStyle", function() {
|
|
|
|
var test = $("div.animateClass"),
|
|
|
|
count = 0;
|
|
|
|
expect(3);
|
2011-05-16 22:19:57 +00:00
|
|
|
test.toggleClass("testAddBorder", minDuration, function() {
|
|
|
|
test.toggleClass("testAddBorder", minDuration, function() {
|
2011-05-12 15:22:49 +00:00
|
|
|
equal( test.css("borderLeftStyle"), "none", "None border set" );
|
|
|
|
start();
|
|
|
|
});
|
|
|
|
equal( test.css("borderLeftStyle"), "solid", "None border not immedately set" );
|
|
|
|
});
|
|
|
|
equal( test.css("borderLeftStyle"), "solid", "Solid border immedately set" );
|
|
|
|
});
|
|
|
|
|
|
|
|
asyncTest( "animateClass works with colors", function() {
|
|
|
|
var test = $("div.animateClass"),
|
|
|
|
count = 0;
|
|
|
|
expect(2);
|
2011-05-16 22:19:57 +00:00
|
|
|
test.toggleClass("testChangeBackground", duration, function() {
|
2011-05-18 23:13:37 +00:00
|
|
|
present( test.css("backgroundColor"), [ "#ffffff", "#fff", "rgb(255, 255, 255)" ], "Color is final" );
|
2011-05-12 15:22:49 +00:00
|
|
|
start();
|
|
|
|
});
|
|
|
|
setTimeout(function() {
|
|
|
|
var color = test.css("backgroundColor");
|
2011-05-18 23:13:37 +00:00
|
|
|
notPresent( color, [ "#000000", "#ffffff", "#000", "#fff", "rgb(0, 0, 0)", "rgb(255,255,255)" ],
|
2011-05-12 15:22:49 +00:00
|
|
|
"Color is not endpoints in middle." );
|
2011-05-16 22:19:57 +00:00
|
|
|
}, mid);
|
2011-05-12 15:22:49 +00:00
|
|
|
});
|
|
|
|
|
2011-05-12 16:13:25 +00:00
|
|
|
asyncTest( "animateClass works with children", function() {
|
|
|
|
var test = $("div.animateClass"),
|
|
|
|
h2 = test.find("h2");
|
2011-05-16 22:19:57 +00:00
|
|
|
|
2011-05-12 16:13:25 +00:00
|
|
|
expect(4);
|
2011-05-18 23:13:37 +00:00
|
|
|
setTimeout(function() {
|
|
|
|
notPresent( h2.css("fontSize"), ["10px","20px"], "Font size is neither endpoint when in middle.");
|
|
|
|
}, mid);
|
2011-05-16 22:19:57 +00:00
|
|
|
test.toggleClass("testChildren", { children: true, duration: duration, complete: function() {
|
2011-05-12 16:13:25 +00:00
|
|
|
equal( h2.css("fontSize"), "20px", "Text size is final during complete");
|
2011-05-16 22:19:57 +00:00
|
|
|
test.toggleClass("testChildren", duration, function() {
|
2011-05-12 16:13:25 +00:00
|
|
|
equal( h2.css("fontSize"), "10px", "Text size revertted after class removed");
|
2011-05-18 23:13:37 +00:00
|
|
|
|
2011-05-12 16:13:25 +00:00
|
|
|
start();
|
|
|
|
});
|
|
|
|
setTimeout(function() {
|
2011-05-18 23:13:37 +00:00
|
|
|
equal( h2.css("fontSize"), "20px", "Text size unchanged during animate with children: undefined" );
|
2011-05-16 22:19:57 +00:00
|
|
|
}, mid);
|
2011-05-12 16:13:25 +00:00
|
|
|
}});
|
|
|
|
});
|
|
|
|
|
2011-03-29 20:32:48 +00:00
|
|
|
})(jQuery);
|