Skip to content
Permalink
Browse files

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

…eprecate select method.
  • Loading branch information...
scottgonzalez committed May 3, 2011
1 parent 75f7a78 commit cbce3585bcd3edb0202839d9533c43d3a6df1d7f
Showing with 40 additions and 24 deletions.
  1. +38 −22 tests/unit/tabs/tabs_deprecated.js
  2. +2 −2 ui/jquery.ui.tabs.js
@@ -338,33 +338,49 @@ test( "remove", function() {
equals( element.tabs( "option", "active" ), false );
});

test('select', function() {
expect(6);
test( "select", function() {
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);
equals(el.tabs('option', 'active'), 1, 'should select tab');
element.tabs({ collapsible: true });
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');
el.tabs({ collapsible: true });
el.tabs('select', 0);
equals(el.tabs('option', 'active'), -1, 'should collapse tab passing in the already active tab');
element.tabs({ collapsible: true });
element.tabs( "select", -1 );
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');
el.tabs({ collapsible: true });
el.tabs('select', -1);
equals(el.tabs('option', 'active'), -1, 'should collapse tab passing in -1');
element.tabs();
tabs_state( element, 1, 0, 0 );
equals( element.tabs( "option", "active" ), 0, "active" );
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');
el.tabs();
el.tabs('select', 0);
equals(el.tabs('option', 'active'), 0, 'should not collapse tab if collapsible is not set to true');
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');
element.tabs( "select", "#fragment-2" );
tabs_state( element, 0, 1, 0 );
equals( element.tabs( "option", "active" ), 1, "active" );
equals( element.tabs( "option", "selected" ), 1, "selected" );
});

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

0 comments on commit cbce358

Please sign in to comment.
You can’t perform that action at this time.