mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Tabs: Added tests for aria-controls attribute being assigned on init.
This commit is contained in:
parent
54016b8469
commit
d573a92beb
@ -72,7 +72,8 @@
|
||||
<li><a href="#colon:test"><span>1</span></a></li>
|
||||
<li><a href="#inline-style"><span>2</span></a></li>
|
||||
<li><a href="data/test.html#test"><span>3</span></a></li>
|
||||
<li><a href="data/test.html" title="∫ßáö Սե"><span>4</span></a></li>
|
||||
<li><a href="data/test.html" aria-controls="custom-id"><span>4</span></a></li>
|
||||
<li><a href="data/test.html" title="∫ßáö Սե"><span>5</span></a></li>
|
||||
</ul>
|
||||
<div id="colon:test"></div>
|
||||
<div style="height: 300px;" id="inline-style"></div>
|
||||
|
@ -4,10 +4,10 @@ module( "tabs: core" );
|
||||
|
||||
test( "markup structure", function() {
|
||||
expect( 3 );
|
||||
var el = $( "#tabs1" ).tabs();
|
||||
ok( el.hasClass( "ui-tabs" ), "main element is .ui-tabs" );
|
||||
ok( el.find( "ul" ).hasClass( "ui-tabs-nav" ), "list item is .ui-tabs-nav" );
|
||||
equal( el.find( ".ui-tabs-panel" ).length, 3,
|
||||
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,
|
||||
".ui-tabs-panel elements exist, correct number" );
|
||||
});
|
||||
|
||||
@ -19,13 +19,30 @@ $.each({
|
||||
}, function( type, selector ) {
|
||||
test( "markup structure: " + type, function() {
|
||||
expect( 2 );
|
||||
var el = $( selector ).tabs();
|
||||
ok( el.hasClass( "ui-tabs" ), "main element is .ui-tabs" );
|
||||
var element = $( selector ).tabs();
|
||||
ok( element.hasClass( "ui-tabs" ), "main element is .ui-tabs" );
|
||||
ok( $( selector + "-list" ).hasClass( "ui-tabs-nav" ),
|
||||
"list item is .ui-tabs-nav" );
|
||||
});
|
||||
});
|
||||
|
||||
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" );
|
||||
});
|
||||
|
||||
test( "accessibility", function() {
|
||||
// TODO: add tests
|
||||
});
|
||||
|
@ -71,7 +71,8 @@
|
||||
<li><a href="#colon:test"><span>1</span></a></li>
|
||||
<li><a href="#inline-style"><span>2</span></a></li>
|
||||
<li><a href="data/test.html#test"><span>3</span></a></li>
|
||||
<li><a href="data/test.html" title="∫ßáö Սե"><span>4</span></a></li>
|
||||
<li><a href="data/test.html" aria-controls="custom-id"><span>4</span></a></li>
|
||||
<li><a href="data/test.html" title="∫ßáö Սե"><span>5</span></a></li>
|
||||
</ul>
|
||||
<div id="colon:test"></div>
|
||||
<div style="height: 300px;" id="inline-style"></div>
|
||||
|
@ -11,7 +11,7 @@ test( "panel ids", function() {
|
||||
equal( ui.panel.attr( "id" ), "∫ßáö_Սե", "from title attribute" );
|
||||
event.preventDefault();
|
||||
});
|
||||
element.tabs( "option", "active", 3 );
|
||||
element.tabs( "option", "active", 4 );
|
||||
|
||||
element.one( "tabsbeforeload", function( event, ui ) {
|
||||
ok( /^ui-tabs-\d+$/.test( ui.panel.attr( "id" ) ), "generated id" );
|
||||
@ -329,7 +329,7 @@ test( "length", function() {
|
||||
expect( 2 );
|
||||
|
||||
equals( $( "#tabs1" ).tabs().tabs( "length" ), 3, "basic tabs" );
|
||||
equals( $( "#tabs2" ).tabs().tabs( "length" ), 4, "ajax tabs with missing panels" );
|
||||
equals( $( "#tabs2" ).tabs().tabs( "length" ), 5, "ajax tabs with missing panels" );
|
||||
});
|
||||
|
||||
test( "url", function() {
|
||||
|
@ -163,10 +163,10 @@ test( "beforeLoad", function() {
|
||||
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
|
||||
equals( ui.panel.html(), "", "panel html" );
|
||||
event.preventDefault();
|
||||
tabs_state( element, 1, 0, 0, 0 );
|
||||
tabs_state( element, 1, 0, 0, 0, 0 );
|
||||
});
|
||||
element.tabs( "option", "active", 2 );
|
||||
tabs_state( element, 0, 0, 1, 0 );
|
||||
tabs_state( element, 0, 0, 1, 0, 0 );
|
||||
equals( panel.html(), "", "panel html after" );
|
||||
|
||||
// click, change panel content
|
||||
@ -184,10 +184,10 @@ test( "beforeLoad", function() {
|
||||
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
|
||||
ui.panel.html( "<p>testing</p>" );
|
||||
event.preventDefault();
|
||||
tabs_state( element, 0, 0, 1, 0 );
|
||||
tabs_state( element, 0, 0, 1, 0, 0 );
|
||||
});
|
||||
element.find( ".ui-tabs-nav a" ).eq( 3 ).click();
|
||||
tabs_state( element, 0, 0, 0, 1 );
|
||||
tabs_state( element, 0, 0, 0, 1, 0 );
|
||||
equals( panel.html(), "<p>testing</p>", "panel html after" );
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user