diff options
author | David Petersen <public@petersendidit.com> | 2011-02-06 14:49:42 -0500 |
---|---|---|
committer | David Petersen <public@petersendidit.com> | 2011-03-21 09:18:19 -0400 |
commit | 710d7620e7f713677a21fc5a8572581250499dd3 (patch) | |
tree | 04acd05f3051560553bd18c5927ee4dd01232dcd /tests/unit/tabs/tabs_methods.js | |
parent | 5bc57a82c8a0bf89694ffc0744d9a6d3095b02b9 (diff) | |
download | jquery-ui-710d7620e7f713677a21fc5a8572581250499dd3.tar.gz jquery-ui-710d7620e7f713677a21fc5a8572581250499dd3.zip |
Tabs: Fix disable and enable methods to correctly handle when index is undefined. Use boolean when fully enabled/disabled. Allow selected tab to be disabled.Fixes #4386
Diffstat (limited to 'tests/unit/tabs/tabs_methods.js')
-rw-r--r-- | tests/unit/tabs/tabs_methods.js | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/tests/unit/tabs/tabs_methods.js b/tests/unit/tabs/tabs_methods.js index bfd9d7713..0209af697 100644 --- a/tests/unit/tabs/tabs_methods.js +++ b/tests/unit/tabs/tabs_methods.js @@ -73,16 +73,32 @@ test('destroy', function() { }); test('enable', function() { - expect(2); + expect(8); el = $('#tabs1').tabs({ disabled: [ 0, 1 ] }); el.tabs("enable", 1); ok( $('li:eq(1)', el).is(':not(.ui-state-disabled)'), 'remove class from li'); - same(el.tabs('option', 'disabled'), [ ], 'update property'); + same(el.tabs('option', 'disabled'), [ 0 ], 'update property'); + + // enable all tabs + el.tabs({ disabled: [ 0, 1 ] }); + el.tabs("enable"); + ok( !$('li.ui-state-disabled', el).length, 'enable all'); + same(el.tabs('option', 'disabled'), false, 'update property'); + + el.tabs('destroy'); + // enable all tabs one by one + el.tabs({ disabled: [ 1, 2 ] }); + el.tabs("enable", 1); + ok( $('li:eq(1)', el).is(':not(.ui-state-disabled)'), 'remove class from li'); + same(el.tabs('option', 'disabled'), [ 2 ], 'update property'); + el.tabs("enable", 2); + ok( $('li:eq(2)', el).is(':not(.ui-state-disabled)'), 'remove class from li'); + same( el.tabs('option', 'disabled'), false, 'set to false'); }); test('disable', function() { - expect(4); + expect(12); // normal el = $('#tabs1').tabs(); @@ -90,10 +106,28 @@ test('disable', function() { ok( $('li:eq(1)', el).is('.ui-state-disabled'), 'add class to li'); same(el.tabs('option', 'disabled'), [ 1 ], 'update disabled property'); - // attempt to disable selected has no effect + // disable selected el.tabs('disable', 0); - ok( $('li:eq(0)', el).is(':not(.ui-state-disabled)'), 'not add class to li'); - same(el.tabs('option', 'disabled'), [ 1 ], 'not update property'); + ok( $('li:eq(0)', el).is('.ui-state-disabled'), 'add class to selected li'); + same(el.tabs('option', 'disabled'), [ 0, 1 ], 'update disabled property'); + + // disable all tabs + el.tabs('disable'); + same( $('li.ui-state-disabled', el).length, 3, 'disable all'); + same(el.tabs('option', 'disabled'), true, 'set to true'); + + el.tabs("destroy"); + // disable all tabs one by one + el.tabs(); + el.tabs('disable', 0); + ok( $('li:eq(0)', el).is('.ui-state-disabled'), 'add class to li'); + same(el.tabs('option', 'disabled'), [ 0 ], 'update disabled property'); + el.tabs('disable', 1); + ok( $('li:eq(1)', el).is('.ui-state-disabled'), 'add class to li'); + same(el.tabs('option', 'disabled'), [ 0, 1 ], 'update disabled property'); + el.tabs('disable', 2); + ok( $('li:eq(2)', el).is('.ui-state-disabled'), 'add class to li'); + same(el.tabs('option', 'disabled'), true, 'set to true'); }); test('add', function() { |