Tabs: Added tests for deprecated select method. Fixes #7138 - Tabs: Deprecate select method.

This commit is contained in:
Scott González 2011-05-03 07:48:08 -04:00
parent 75f7a786ae
commit cbce3585bc
2 changed files with 40 additions and 24 deletions

View File

@ -338,33 +338,49 @@ test( "remove", function() {
equals( element.tabs( "option", "active" ), false ); equals( element.tabs( "option", "active" ), false );
}); });
test('select', function() { test( "select", function() {
expect(6); expect( 23 );
el = $('#tabs1').tabs(); var element = $( "#tabs1" ).tabs();
tabs_state( element, 1, 0, 0 );
element.tabs( "select", 1 );
tabs_state( element, 0, 1, 0 );
equals( element.tabs( "option", "active" ), 1, "active" );
equals( element.tabs( "option", "selected" ), 1, "selected" );
element.tabs( "destroy" );
el.tabs('select', 1); element.tabs({ collapsible: true });
equals(el.tabs('option', 'active'), 1, 'should select tab'); tabs_state( element, 1, 0, 0 );
element.tabs( "select", 0 );
tabs_state( element, 0, 0, 0 );
equals( element.tabs( "option", "active" ), false, "active" );
equals( element.tabs( "option", "selected" ), -1, "selected" );
element.tabs( "destroy" );
el.tabs('destroy'); element.tabs({ collapsible: true });
el.tabs({ collapsible: true }); element.tabs( "select", -1 );
el.tabs('select', 0); tabs_state( element, 0, 0, 0 );
equals(el.tabs('option', 'active'), -1, 'should collapse tab passing in the already active tab'); equals( element.tabs( "option", "active" ), false, "active" );
equals( element.tabs( "option", "selected" ), -1, "selected" );
element.tabs( "destroy" );
el.tabs('destroy'); element.tabs();
el.tabs({ collapsible: true }); tabs_state( element, 1, 0, 0 );
el.tabs('select', -1); equals( element.tabs( "option", "active" ), 0, "active" );
equals(el.tabs('option', 'active'), -1, 'should collapse tab passing in -1'); equals( element.tabs( "option", "selected" ), 0, "selected" );
element.tabs( "select", 0 );
tabs_state( element, 1, 0, 0 );
equals( element.tabs( "option", "active" ), 0, "active" );
equals( element.tabs( "option", "selected" ), 0, "selected" );
element.tabs( "select", -1 );
tabs_state( element, 1, 0, 0 );
equals( element.tabs( "option", "active" ), 0, "active" );
equals( element.tabs( "option", "selected" ), 0, "selected" );
el.tabs('destroy'); element.tabs( "select", "#fragment-2" );
el.tabs(); tabs_state( element, 0, 1, 0 );
el.tabs('select', 0); equals( element.tabs( "option", "active" ), 1, "active" );
equals(el.tabs('option', 'active'), 0, 'should not collapse tab if collapsible is not set to true'); equals( element.tabs( "option", "selected" ), 1, "selected" );
el.tabs('select', -1);
equals(el.tabs('option', 'active'), 0, 'should not collapse tab if collapsible is not set to true');
el.tabs('select', '#fragment-2');
equals(el.tabs('option', 'active'), 1, 'should select tab by id');
}); });
test( "length", function() { test( "length", function() {

View File

@ -998,8 +998,8 @@ if ( $.uiBackCompat !== false ) {
(function( $, prototype ) { (function( $, prototype ) {
prototype.select = function( index ) { prototype.select = function( index ) {
index = this._getIndex( index ); index = this._getIndex( index );
if ( index == -1 ) { if ( index === -1 ) {
if ( this.options.collapsible && this.options.selected != -1 ) { if ( this.options.collapsible && this.options.selected !== -1 ) {
index = this.options.selected; index = this.options.selected;
} else { } else {
return; return;