From cbce3585bcd3edb0202839d9533c43d3a6df1d7f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 3 May 2011 07:48:08 -0400 Subject: [PATCH] Tabs: Added tests for deprecated select method. Fixes #7138 - Tabs: Deprecate select method. --- tests/unit/tabs/tabs_deprecated.js | 60 +++++++++++++++++++----------- ui/jquery.ui.tabs.js | 4 +- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js index e61e6ec29..90c43037c 100644 --- a/tests/unit/tabs/tabs_deprecated.js +++ b/tests/unit/tabs/tabs_deprecated.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() { diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 8bef69290..58c181670 100755 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -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; -- 2.39.5