mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Unit Tests: effects: adding some animateClass tests
This commit is contained in:
parent
783f134aaa
commit
e4204b129d
@ -35,6 +35,22 @@
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
.test {
|
||||
background: #000;
|
||||
border: 0;
|
||||
}
|
||||
.testAddBorder {
|
||||
border: 10px solid #000;
|
||||
}
|
||||
.testChangeBackground {
|
||||
background: #fff;
|
||||
}
|
||||
.test h2 {
|
||||
font-size: 10px;
|
||||
}
|
||||
.testChildren h2 {
|
||||
font-size: 20px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@ -48,7 +64,9 @@
|
||||
|
||||
<div id="qunit-fixture">
|
||||
<div class="hidden test"></div>
|
||||
<div class="shown test"></div>
|
||||
<div class="animateClass test">
|
||||
<h2>Child Element Test</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
@ -1,5 +1,13 @@
|
||||
(function($) {
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
var animateTime = 15;
|
||||
|
||||
module( "effects.core" );
|
||||
@ -8,12 +16,10 @@ $.each( $.effects.effect, function( effect ) {
|
||||
if ( effect === "transfer" ) {
|
||||
return;
|
||||
}
|
||||
QUnit.reset();
|
||||
module( "effect."+effect );
|
||||
test( "show/hide", function() {
|
||||
asyncTest( "show/hide", function() {
|
||||
var hidden = $( "div.hidden" );
|
||||
expect( 8 );
|
||||
stop();
|
||||
|
||||
var count = 0,
|
||||
test = 0;
|
||||
@ -23,13 +29,13 @@ $.each( $.effects.effect, function( effect ) {
|
||||
var point = count;
|
||||
return function( next ) {
|
||||
test++;
|
||||
equals( point, test, "Queue function fired in order" );
|
||||
equal( point, test, "Queue function fired in order" );
|
||||
if ( fn ) {
|
||||
fn ()
|
||||
fn ();
|
||||
} else {
|
||||
setTimeout( next, animateTime );
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
hidden.queue( queueTest() ).show( effect, animateTime, queueTest(function() {
|
||||
@ -37,10 +43,41 @@ $.each( $.effects.effect, function( effect ) {
|
||||
})).queue( queueTest() ).hide( effect, animateTime, queueTest(function() {
|
||||
equal( hidden.css("display"), "none", "Back to hidden after .hide(\"" +effect+ "\", time)" );
|
||||
})).queue( queueTest(function(next) {
|
||||
deepEqual( hidden.queue(), ["inprogress"], "Only the inprogress sentinel remains")
|
||||
deepEqual( hidden.queue(), ["inprogress"], "Only the inprogress sentinel remains");
|
||||
start();
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
module("animateClass");
|
||||
|
||||
asyncTest( "animateClass works with borderStyle", function() {
|
||||
var test = $("div.animateClass"),
|
||||
count = 0;
|
||||
expect(3);
|
||||
test.toggleClass("testAddBorder", 20, function() {
|
||||
test.toggleClass("testAddBorder", 20, function() {
|
||||
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);
|
||||
test.toggleClass("testChangeBackground", 100, function() {
|
||||
present( test.css("backgroundColor"), [ "#ffffff", "rgb(255, 255, 255)" ], "Color is final" );
|
||||
start();
|
||||
});
|
||||
setTimeout(function() {
|
||||
var color = test.css("backgroundColor");
|
||||
notPresent( color, [ "#000000", "#ffffff", "rgb(0, 0, 0)", "rgb(255,255,255)" ],
|
||||
"Color is not endpoints in middle." );
|
||||
}, 50);
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
Loading…
Reference in New Issue
Block a user