diff options
author | Klaus Hartl <klaus.hartl@googlemail.com> | 2009-01-25 23:42:56 +0000 |
---|---|---|
committer | Klaus Hartl <klaus.hartl@googlemail.com> | 2009-01-25 23:42:56 +0000 |
commit | a7c0141875b48608daf70e54f5e37214418a77ae (patch) | |
tree | 5c362f7e09594fd2662c32e30b034ee7c8a5e7f6 /tests | |
parent | 80dd45b6937b16578610e244832938ab4a075c64 (diff) | |
download | jquery-ui-a7c0141875b48608daf70e54f5e37214418a77ae.tar.gz jquery-ui-a7c0141875b48608daf70e54f5e37214418a77ae.zip |
Tabs: overall fixed selected property for all tabs unselected case (is -1 in such case), added sanity check for selected out of bound, fixes #3936
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/tabs/tabs.js | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/tests/unit/tabs/tabs.js b/tests/unit/tabs/tabs.js index 90c52a246..916db903b 100644 --- a/tests/unit/tabs/tabs.js +++ b/tests/unit/tabs/tabs.js @@ -123,22 +123,41 @@ module('tabs'); }); - + test('selected property', function() { + expect(5); + + $('#tabs1').tabs(); + equals($('#tabs1').data('selected.tabs'), 0, 'selected should be 0 by default'); + + reset(); + $('#tabs1').tabs({ selected: null }); + equals($('#tabs1').data('selected.tabs'), -1, 'selected should be -1 for all tabs unselected'); + + reset(); + $('#tabs1').tabs({ selected: -1 }); + equals($('#tabs1').data('selected.tabs'), -1, 'selected should be -1 for all tabs unselected'); + + reset(); + $('#tabs1').tabs({ selected: 1 }); + equals($('#tabs1').data('selected.tabs'), 1, 'selected should be specified tab'); + + reset(); + $('#tabs1').tabs({ selected: 8 }); + equals($('#tabs1').data('selected.tabs'), 0, 'selected should default to zero if given value is out of index'); + + }); + module('tabs: Options'); - test('select: null', function() { - expect(3); + test('selected: null', function() { + expect(2); - var el = $('#tabs1 > ul'); + var el = $('#tabs1'); el.tabs({ selected: null }); - equals( el.data('selected.tabs'), null, 'option set' ); - equals( $('li.ui-tabs-selected', el).length, 0, 'all tabs should be deselected' ); + equals( $('li.ui-tabs-selected', el).length, 0, 'no tab should be selected' ); equals( $('div.ui-tabs-hide', '#tabs1').length, 3, 'all panels should be hidden' ); - // TODO select == null with cookie - // TODO select == null with select method - }); test('deselectable: true', function() { @@ -164,7 +183,7 @@ module('tabs: Options'); }); test('cookie', function() { - expect(5); + expect(6); var el = $('#tabs1 > ul'); var cookieName = 'ui-tabs-' + $.data(el[0]); @@ -189,6 +208,11 @@ module('tabs: Options'); equals(cookie(), 1, 'initial cookie value, from existing cookie'); el.tabs('destroy'); + el.tabs({ cookie: {}, deselectable: true }); + el.tabs('select', 0); + equals(cookie(), -1, 'cookie value for all unselected tabs'); + + el.tabs('destroy'); ok($.cookie(cookieName) === null, 'erase cookie after destroy'); }); |