aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgnarf <gnarf@gnarf.net>2011-05-12 10:22:49 -0500
committergnarf <gnarf@gnarf.net>2011-05-12 10:22:49 -0500
commite4204b129dc2ae4b8fe865b2c9cb381bb97de3eb (patch)
tree14a733d050dd64ffe4a87010deabaa5ab9094b39
parent783f134aaa333b9e8795c701d8fd741de387cb0e (diff)
downloadjquery-ui-e4204b129dc2ae4b8fe865b2c9cb381bb97de3eb.tar.gz
jquery-ui-e4204b129dc2ae4b8fe865b2c9cb381bb97de3eb.zip
Unit Tests: effects: adding some animateClass tests
-rw-r--r--tests/unit/effects/effects.html20
-rw-r--r--tests/unit/effects/effects_core.js51
2 files changed, 63 insertions, 8 deletions
diff --git a/tests/unit/effects/effects.html b/tests/unit/effects/effects.html
index 2cffda7ec..0879a98b2 100644
--- a/tests/unit/effects/effects.html
+++ b/tests/unit/effects/effects.html
@@ -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>
diff --git a/tests/unit/effects/effects_core.js b/tests/unit/effects/effects_core.js
index 0359b73d3..228b6a79c 100644
--- a/tests/unit/effects/effects_core.js
+++ b/tests/unit/effects/effects_core.js
@@ -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);