diff options
author | Scott González <scott.gonzalez@gmail.com> | 2011-05-10 14:04:50 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2011-05-10 14:04:50 -0400 |
commit | 85ac420a1e4281ee7f361e847d3cad72fa58525e (patch) | |
tree | 21f3e78605024015cf5cd1e9c1b1d78e104bd1d2 /tests/unit/tabs | |
parent | 7fddb1c5b5137887f6c145f54e47f946ceb9741d (diff) | |
download | jquery-ui-85ac420a1e4281ee7f361e847d3cad72fa58525e.tar.gz jquery-ui-85ac420a1e4281ee7f361e847d3cad72fa58525e.zip |
Tabs: Fixed select event.
Diffstat (limited to 'tests/unit/tabs')
-rw-r--r-- | tests/unit/tabs/tabs_deprecated.js | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js index 539e9b94d..4b50df405 100644 --- a/tests/unit/tabs/tabs_deprecated.js +++ b/tests/unit/tabs/tabs_deprecated.js @@ -267,7 +267,7 @@ test( "show", function() { ok( !( "originalEvent" in event ), "originalEvent" ); strictEqual( ui.tab, tabs[ 0 ], "ui.tab" ); strictEqual( ui.panel, panels[ 0 ], "ui.panel" ); - equal( ui.index, 0 ); + equal( ui.index, 0, "ui.index" ); tabs_state( element, 1, 0, 0 ); }); element.tabs( "option", "active", 0 ); @@ -278,7 +278,7 @@ test( "show", function() { equals( event.originalEvent.type, "click", "originalEvent" ); strictEqual( ui.tab, tabs[ 1 ], "ui.tab" ); strictEqual( ui.panel, panels[ 1 ], "ui.panel" ); - equal( ui.index, 1 ); + equal( ui.index, 1, "ui.index" ); tabs_state( element, 0, 1, 0 ); }); tabs.eq( 1 ).click(); @@ -292,25 +292,44 @@ test( "show", function() { tabs_state( element, 0, 0, 0 ); }); -test('select', function() { - expect(7); +test( "select", function() { + expect( 13 ); - var eventObj; - el = $('#tabs1').tabs({ - select: function(event, ui) { - ok(true, 'select triggered after initialization'); - equals(this, el[0], "context of callback"); - equals(event.type, 'tabsselect', 'event type in callback'); - equals(ui.tab, el.find('a')[1], 'contain tab as DOM anchor element'); - equals(ui.panel, el.find('div')[1], 'contain panel as DOM div element'); - equals(ui.index, 1, 'contain index'); - evenObj = event; - } + var element = $( "#tabs1" ).tabs({ + active: false, + collapsible: true + }), + tabs = element.find( ".ui-tabs-nav a" ), + panels = element.find( ".ui-tabs-panel" ); + + // from collapsed + element.one( "tabsselect", function( event, ui ) { + ok( !( "originalEvent" in event ), "originalEvent" ); + strictEqual( ui.tab, tabs[ 0 ], "ui.tab" ); + strictEqual( ui.panel, panels[ 0 ], "ui.panel" ); + equal( ui.index, 0, "ui.index" ); + tabs_state( element, 0, 0, 0 ); }); - el.tabs('select', 1); + element.tabs( "option", "active", 0 ); + tabs_state( element, 1, 0, 0 ); - el.find( "li:eq(1) a" ).simulate( "click" ); - equals( evenObj.originalEvent.type, "click", "select triggered by click" ); + // switching tabs + element.one( "tabsselect", function( event, ui ) { + equals( event.originalEvent.type, "click", "originalEvent" ); + strictEqual( ui.tab, tabs[ 1 ], "ui.tab" ); + strictEqual( ui.panel, panels[ 1 ], "ui.panel" ); + equal( ui.index, 1, "ui.index" ); + tabs_state( element, 1, 0, 0 ); + }); + tabs.eq( 1 ).click(); + tabs_state( element, 0, 1, 0 ); + + // collapsing + element.one( "tabsselect", function( event, ui ) { + ok( false, "collapsing" ); + }); + element.tabs( "option", "active", false ); + tabs_state( element, 0, 0, 0 ); }); module( "tabs (deprecated): methods" ); |