diff options
author | Felix Nagel <info@felixnagel.com> | 2012-11-12 23:28:24 +0100 |
---|---|---|
committer | Felix Nagel <info@felixnagel.com> | 2012-11-12 23:28:24 +0100 |
commit | daec559c981a410089f3c0d310f6a5986142c9a5 (patch) | |
tree | 7fdb3fff84f70ef135af5f2ba0064f519db6d70a /tests/unit | |
parent | 967e2b74b2e6f1a8e908f060369c3ef51f0cbd7e (diff) | |
parent | 902df84fce790178da78c5830498911a487d50cf (diff) | |
download | jquery-ui-daec559c981a410089f3c0d310f6a5986142c9a5.tar.gz jquery-ui-daec559c981a410089f3c0d310f6a5986142c9a5.zip |
Merge branch 'master' into selectmenu
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/accordion/accordion_methods.js | 63 | ||||
-rw-r--r-- | tests/unit/button/button_tickets.js | 11 | ||||
-rw-r--r-- | tests/unit/testsuite.js | 17 |
3 files changed, 87 insertions, 4 deletions
diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js index f8f556fa7..b1123b828 100644 --- a/tests/unit/accordion/accordion_methods.js +++ b/tests/unit/accordion/accordion_methods.js @@ -30,7 +30,7 @@ test( "enable/disable", function() { }); test( "refresh", function() { - expect( 6 ); + expect( 17 ); var element = $( "#navigation" ) .parent() .height( 300 ) @@ -43,6 +43,67 @@ test( "refresh", function() { element.parent().height( 500 ); element.accordion( "refresh" ); equalHeight( element, 455 ); + + element = $( "#list1" ); + element.accordion(); + state( element, 1, 0, 0 ); + + // disable panel via markup + element.find( "h3.bar" ).eq( 1 ).addClass( "ui-state-disabled" ); + element.accordion( "refresh" ); + state( element, 1, 0, 0 ); + + // don't add multiple icons + element.accordion( "refresh" ); + equal( element.find( ".ui-accordion-header-icon" ).length, 3 ); + + // add a panel + element + .append("<h3 class='bar' id='new_1'>new 1</h3>") + .append("<div class='foo' id='new_1_panel'>new 1</div>"); + element.accordion( "refresh" ); + state( element, 1, 0, 0, 0 ); + + // remove all tabs + element.find( "h3.bar, div.foo" ).remove(); + element.accordion( "refresh" ); + state( element ); + equal( element.accordion( "option", "active" ), false, "no active accordion panel" ); + + // add panels + element + .append("<h3 class='bar' id='new_2'>new 2</h3>") + .append("<div class='foo' id='new_2_panel'>new 2</div>") + .append("<h3 class='bar' id='new_3'>new 3</h3>") + .append("<div class='foo' id='new_3_panel'>new 3</div>") + .append("<h3 class='bar' id='new_4'>new 4</h3>") + .append("<div class='foo' id='new_4_panel'>new 4</div>") + .append("<h3 class='bar' id='new_5'>new 5</h3>") + .append("<div class='foo' id='new_5_panel'>new 5</div>"); + element.accordion( "refresh" ); + state( element, 1, 0, 0, 0 ); + + // activate third tab + element.accordion( "option", "active", 2 ); + state( element, 0, 0, 1, 0 ); + + // remove fourth panel, third panel should stay active + element.find( "h3.bar" ).eq( 3 ).remove(); + element.find( "div.foo" ).eq( 3 ).remove(); + element.accordion( "refresh" ); + state( element, 0, 0, 1 ); + + // remove third (active) panel, second panel should become active + element.find( "h3.bar" ).eq( 2 ).remove(); + element.find( "div.foo" ).eq( 2 ).remove(); + element.accordion( "refresh" ); + state( element, 0, 1 ); + + // remove first panel, previously active panel (now first) should stay active + element.find( "h3.bar" ).eq( 0 ).remove(); + element.find( "div.foo" ).eq( 0 ).remove(); + element.accordion( "refresh" ); + state( element, 1 ); }); test( "widget", function() { diff --git a/tests/unit/button/button_tickets.js b/tests/unit/button/button_tickets.js index eb70181ec..1e901f9d1 100644 --- a/tests/unit/button/button_tickets.js +++ b/tests/unit/button/button_tickets.js @@ -5,6 +5,17 @@ module( "button: tickets" ); +test( "#5295 - button does not remove hoverstate if disabled" , function() { + expect( 1 ); + var btn = $("#button").button(); + btn.hover( function() { + btn.button( "disable" ); + }); + btn.trigger( "mouseenter" ); + btn.trigger( "mouseleave" ); + ok( !btn.is( ".ui-state-hover") ); +}); + test( "#5946 - buttonset should ignore buttons that are not :visible", function() { expect( 2 ); $( "#radio01" ).next().andSelf().hide(); diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js index f3c0982fb..42fdf4f9e 100644 --- a/tests/unit/testsuite.js +++ b/tests/unit/testsuite.js @@ -271,11 +271,22 @@ window.domEqual = function( selector, modifier, message ) { } return result; } + + function done() { + actual = extract( $( selector ) ); + QUnit.push( QUnit.equiv(actual, expected), actual, expected, message ); + } + + // Get current state prior to modifier expected = extract( $( selector ) ); - modifier( $( selector ) ); - actual = extract( $( selector ) ); - QUnit.push( QUnit.equiv(actual, expected), actual, expected, message ); + // Run modifier (async or sync), then compare state via done() + if ( modifier.length ) { + modifier( done ); + } else { + modifier(); + done(); + } }; }( jQuery )); |