@@ -86,7 +86,7 @@ test( "disable( index )", function() {
8686} ) ;
8787
8888test ( 'refresh' , function ( ) {
89- expect ( 5 ) ;
89+ expect ( 13 ) ;
9090
9191 var el = $ ( '<div id="tabs"><ul></ul></div>' ) . tabs ( ) ,
9292 ul = el . find ( 'ul' ) ;
@@ -95,22 +95,45 @@ test('refresh', function() {
9595
9696 ul . append ( '<li><a href="data/test.html">Test 1</a></li>' ) ;
9797 el . tabs ( 'refresh' ) ;
98+ equals ( el . tabs ( 'option' , 'active' ) , 0 , 'First tab added should be auto active' ) ;
99+ ok ( $ ( "li:eq(0)" , el ) . is ( '.ui-tabs-active' ) , 'First tab should be auto active' ) ;
98100 equals ( el . find ( '.ui-tabs-panel' ) . length , 1 , 'Panel created after refresh' ) ;
99101
100102 ul . find ( 'li' ) . remove ( ) ;
101103 el . tabs ( 'refresh' ) ;
102104 equals ( el . find ( '.ui-tabs-panel' ) . length , 0 , 'Panel removed after refresh' ) ;
105+ equals ( el . tabs ( 'option' , 'active' ) , false , 'No tabs are active' ) ;
103106
104- ul . append ( '<li><a href="#test1">Test 1</a></li>' ) ;
105- $ ( '<div id="test1">Test Panel 1</div>' ) . insertAfter ( ul ) ;
107+ // Hide second tab
108+ $ ( '<li><a href="#test1">Test 1</a></li><li><a href="#test2">Test 2</a></li><li><a href="#test3">Test 3</a></li>' )
109+ . appendTo ( ul ) ;
110+ $ ( '<div id="test1">Test Panel 1</div><div id="test2">Test Panel 2</div><div id="test3">Test Panel 3</div>' )
111+ . insertAfter ( ul ) ;
106112 el . tabs ( 'refresh' ) ;
107- el . tabs ( 'option' , 'active' , 0 ) ;
108- equals ( el . tabs ( 'option' , 'active' ) , 0 , 'First tab added should be auto active ' ) ;
113+ equals ( el . tabs ( 'option' , 'active' ) , 0 , 'Second tab added should not be auto active' ) ;
114+ equals ( $ ( "#test2" , el ) . css ( "display" ) , "none" , 'Second panel is hidden ' ) ;
109115
110- ul . append ( '<li><a href="#test2">Test 2</a></li>' ) ;
111- $ ( '<div id="test2">Test Panel 2</div>' ) . insertAfter ( ul ) ;
116+ // Make second tab active and then remove the first one
117+ el . tabs ( 'option' , 'active' , 1 ) ;
118+ el . find ( 'a[href="#test1"]' ) . parent ( ) . remove ( ) ;
112119 el . tabs ( 'refresh' ) ;
113- equals ( el . tabs ( 'option' , 'active' ) , 0 , 'Second tab added should not be auto active' ) ;
120+ equals ( el . tabs ( 'option' , 'active' ) , 0 , 'Active index correctly updated' ) ;
121+ ok ( el . find ( 'a[href="#test2"]' ) . parent ( ) . is ( '.ui-tabs-active' ) , 'Tab is still active' ) ;
122+
123+ // Refresh with disabled tabs
124+ el . tabs ( 'disable' , 1 ) ;
125+ same ( el . tabs ( 'option' , 'disabled' ) , [ 1 ] , 'Second tab disabled' ) ;
126+
127+ el . find ( 'a[href="#test3"]' ) . remove ( ) ;
128+ ul . append ( '<li><a href="#test4">Test 4</a></li>' ) ;
129+ $ ( '<div id="test4">Test Panel 4</div>' ) . insertAfter ( ul ) ;
130+ el . tabs ( 'refresh' ) ;
131+ equals ( el . tabs ( 'option' , 'disabled' ) , false , 'Not disabled' ) ;
132+
133+ ul . append ( '<li class="ui-state-disabled"><a href="#test3">Test 3</a></li>' ) ;
134+ $ ( '<div id="test3">Test Panel 3</div>' ) . insertAfter ( ul ) ;
135+ el . tabs ( 'refresh' ) ;
136+ same ( el . tabs ( 'option' , 'disabled' ) , [ 2 ] , 'Second tab disabled' ) ;
114137} ) ;
115138
116139test ( 'load' , function ( ) {
0 commit comments