2011-04-04 14:11:19 +00:00
|
|
|
(function( $ ) {
|
2009-02-04 09:35:52 +00:00
|
|
|
|
2011-04-04 14:11:19 +00:00
|
|
|
module( "tabs: core" );
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2011-04-04 14:11:19 +00:00
|
|
|
test( "markup structure", function() {
|
|
|
|
expect( 3 );
|
2011-04-07 17:53:20 +00:00
|
|
|
var element = $( "#tabs1" ).tabs();
|
|
|
|
ok( element.hasClass( "ui-tabs" ), "main element is .ui-tabs" );
|
|
|
|
ok( element.find( "ul" ).hasClass( "ui-tabs-nav" ), "list item is .ui-tabs-nav" );
|
|
|
|
equal( element.find( ".ui-tabs-panel" ).length, 3,
|
2011-04-04 14:11:19 +00:00
|
|
|
".ui-tabs-panel elements exist, correct number" );
|
|
|
|
});
|
2009-12-25 18:25:46 +00:00
|
|
|
|
2011-04-04 14:11:19 +00:00
|
|
|
$.each({
|
|
|
|
"deep ul": "#tabs3",
|
|
|
|
"multiple lists, ul first": "#tabs4",
|
|
|
|
"multiple lists, ol first": "#tabs5",
|
|
|
|
"empty list": "#tabs6"
|
|
|
|
}, function( type, selector ) {
|
|
|
|
test( "markup structure: " + type, function() {
|
|
|
|
expect( 2 );
|
2011-04-07 17:53:20 +00:00
|
|
|
var element = $( selector ).tabs();
|
|
|
|
ok( element.hasClass( "ui-tabs" ), "main element is .ui-tabs" );
|
2011-04-04 14:11:19 +00:00
|
|
|
ok( $( selector + "-list" ).hasClass( "ui-tabs-nav" ),
|
|
|
|
"list item is .ui-tabs-nav" );
|
|
|
|
});
|
|
|
|
});
|
2009-12-25 18:25:46 +00:00
|
|
|
|
2011-04-15 15:04:49 +00:00
|
|
|
// #5893 - Sublist in the tab list are considered as tab
|
|
|
|
test( "nested list", function() {
|
|
|
|
expect( 1 );
|
|
|
|
|
|
|
|
var element = $( "#tabs6" ).tabs();
|
|
|
|
equals( element.data( "tabs" ).anchors.length, 2, "should contain 2 tab" );
|
|
|
|
});
|
|
|
|
|
|
|
|
test( "disconnected from DOM", function() {
|
|
|
|
expect( 2 );
|
|
|
|
|
|
|
|
var element = $( "#tabs1" ).remove().tabs();
|
|
|
|
equals( element.find( ".ui-tabs-nav" ).length, 1, "should initialize nav" );
|
|
|
|
equals( element.find( ".ui-tabs-panel" ).length, 3, "should initialize panels" );
|
|
|
|
});
|
|
|
|
|
2011-04-07 17:53:20 +00:00
|
|
|
test( "aria-controls", function() {
|
|
|
|
expect( 7 );
|
|
|
|
var element = $( "#tabs1" ).tabs(),
|
|
|
|
tabs = element.find( ".ui-tabs-nav a" );
|
|
|
|
tabs.each(function() {
|
|
|
|
var tab = $( this );
|
|
|
|
equal( tab.attr( "href" ).substring( 1 ), tab.attr( "aria-controls" ) );
|
|
|
|
});
|
|
|
|
|
|
|
|
element = $( "#tabs2" ).tabs();
|
|
|
|
tabs = element.find( ".ui-tabs-nav a" );
|
|
|
|
equal( tabs.eq( 0 ).attr( "aria-controls" ), "colon:test" );
|
|
|
|
equal( tabs.eq( 1 ).attr( "aria-controls" ), "inline-style" );
|
|
|
|
ok( /^ui-tabs-\d+$/.test( tabs.eq( 2 ).attr( "aria-controls" ) ), "generated id" );
|
|
|
|
equal( tabs.eq( 3 ).attr( "aria-controls" ), "custom-id" );
|
|
|
|
});
|
|
|
|
|
2011-04-04 14:11:19 +00:00
|
|
|
test( "accessibility", function() {
|
|
|
|
// TODO: add tests
|
2009-12-25 18:25:46 +00:00
|
|
|
});
|
|
|
|
|
2011-04-04 14:11:19 +00:00
|
|
|
}( jQuery ) );
|