aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2012-03-27 18:05:51 -0400
committerScott González <scott.gonzalez@gmail.com>2012-03-27 18:05:51 -0400
commit4a6692a57aa156dcaa916af66b36f767a25e37c3 (patch)
treecc7ce6460441639b769c7469e170831a62190f5f /tests
parent6634e4005368ded31dce50de7095ed0f8835637c (diff)
downloadjquery-ui-4a6692a57aa156dcaa916af66b36f767a25e37c3.tar.gz
jquery-ui-4a6692a57aa156dcaa916af66b36f767a25e37c3.zip
Accordion: Added animation tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/accordion/accordion_options.js170
1 files changed, 169 insertions, 1 deletions
diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js
index 74a9a3177..2b7176394 100644
--- a/tests/unit/accordion/accordion_options.js
+++ b/tests/unit/accordion/accordion_options.js
@@ -75,7 +75,175 @@ if ( $.uiBackCompat === false ) {
});
}
-// TODO: add animation tests
+test( "{ animate: false }", function() {
+ expect( 3 );
+ var element = $( "#list1" ).accordion({
+ animate: false
+ }),
+ panels = element.find( ".ui-accordion-content" );
+ animate = $.fn.animate;
+ $.fn.animate = function() {
+ ok( false, ".animate() called" );
+ };
+
+ ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
+ element.accordion( "option", "active", 1 );
+ ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
+ ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
+ $.fn.animate = animate;
+});
+
+asyncTest( "{ animate: Number }", function() {
+ expect( 7 );
+ var element = $( "#list1" ).accordion({
+ animate: 100
+ }),
+ panels = element.find( ".ui-accordion-content" );
+ animate = $.fn.animate;
+ // called twice (both panels)
+ $.fn.animate = function( props, duration, easing ) {
+ equal( duration, 100, "correct duration" );
+ equal( easing, undefined, "default easing" );
+ animate.apply( this, arguments );
+ };
+
+ ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
+ element.accordion( "option", "active", 1 );
+ panels.promise().done(function() {
+ ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
+ ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
+ $.fn.animate = animate;
+ start();
+ });
+});
+
+asyncTest( "{ animate: String }", function() {
+ expect( 7 );
+ var element = $( "#list1" ).accordion({
+ animate: "linear"
+ }),
+ panels = element.find( ".ui-accordion-content" );
+ animate = $.fn.animate;
+ // called twice (both panels)
+ $.fn.animate = function( props, duration, easing ) {
+ equal( duration, undefined, "default duration" );
+ equal( easing, "linear", "correct easing" );
+ animate.apply( this, arguments );
+ };
+
+ ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
+ element.accordion( "option", "active", 1 );
+ panels.promise().done(function() {
+ ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
+ ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
+ $.fn.animate = animate;
+ start();
+ });
+});
+
+asyncTest( "{ animate: {} }", function() {
+ expect( 7 );
+ var element = $( "#list1" ).accordion({
+ animate: {}
+ }),
+ panels = element.find( ".ui-accordion-content" );
+ animate = $.fn.animate;
+ // called twice (both panels)
+ $.fn.animate = function( props, duration, easing ) {
+ equal( duration, undefined, "default duration" );
+ equal( easing, undefined, "default easing" );
+ animate.apply( this, arguments );
+ };
+
+ ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
+ element.accordion( "option", "active", 1 );
+ panels.promise().done(function() {
+ ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
+ ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
+ $.fn.animate = animate;
+ start();
+ });
+});
+
+asyncTest( "{ animate: { duration, easing } }", function() {
+ expect( 7 );
+ var element = $( "#list1" ).accordion({
+ animate: { duration: 100, easing: "linear" }
+ }),
+ panels = element.find( ".ui-accordion-content" );
+ animate = $.fn.animate;
+ // called twice (both panels)
+ $.fn.animate = function( props, duration, easing ) {
+ equal( duration, 100, "correct duration" );
+ equal( easing, "linear", "correct easing" );
+ animate.apply( this, arguments );
+ };
+
+ ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
+ element.accordion( "option", "active", 1 );
+ panels.promise().done(function() {
+ ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
+ ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
+ $.fn.animate = animate;
+ start();
+ });
+});
+
+asyncTest( "{ animate: { duration, easing } }, animate down", function() {
+ expect( 7 );
+ var element = $( "#list1" ).accordion({
+ active: 1,
+ animate: { duration: 100, easing: "linear" }
+ }),
+ panels = element.find( ".ui-accordion-content" );
+ animate = $.fn.animate;
+ // called twice (both panels)
+ $.fn.animate = function( props, duration, easing ) {
+ equal( duration, 100, "correct duration" );
+ equal( easing, "linear", "correct easing" );
+ animate.apply( this, arguments );
+ };
+
+ ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" );
+ element.accordion( "option", "active", 0 );
+ panels.promise().done(function() {
+ ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" );
+ ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" );
+ $.fn.animate = animate;
+ start();
+ });
+});
+
+asyncTest( "{ animate: { duration, easing, down } }, animate down", function() {
+ expect( 7 );
+ var element = $( "#list1" ).accordion({
+ active: 1,
+ animate: {
+ duration: 100,
+ easing: "linear",
+ down: {
+ easing: "swing"
+ }
+ }
+ }),
+ panels = element.find( ".ui-accordion-content" );
+ animate = $.fn.animate;
+ // called twice (both panels)
+ $.fn.animate = function( props, duration, easing ) {
+ equal( duration, 100, "correct duration" );
+ equal( easing, "swing", "correct easing" );
+ animate.apply( this, arguments );
+ };
+
+ ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" );
+ element.accordion( "option", "active", 0 );
+ panels.promise().done(function() {
+ ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" );
+ ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" );
+ $.fn.animate = animate;
+ start();
+ });
+});
test( "{ collapsible: false }", function() {
expect( 4 );