diff options
author | Scott González <scott.gonzalez@gmail.com> | 2011-04-07 13:53:20 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2011-04-07 13:53:20 -0400 |
commit | d573a92bebf881d6ad68e4e128b5f534e047ae0c (patch) | |
tree | 295373e9e5c9386a822447e1b9986e2cb31a74fa /tests | |
parent | 54016b8469345a325e8c1ab6f8a7d17b0f0f8d01 (diff) | |
download | jquery-ui-d573a92bebf881d6ad68e4e128b5f534e047ae0c.tar.gz jquery-ui-d573a92bebf881d6ad68e4e128b5f534e047ae0c.zip |
Tabs: Added tests for aria-controls attribute being assigned on init.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/tabs/tabs.html | 3 | ||||
-rw-r--r-- | tests/unit/tabs/tabs_core.js | 29 | ||||
-rw-r--r-- | tests/unit/tabs/tabs_deprecated.html | 3 | ||||
-rw-r--r-- | tests/unit/tabs/tabs_deprecated.js | 4 | ||||
-rw-r--r-- | tests/unit/tabs/tabs_events.js | 8 |
5 files changed, 33 insertions, 14 deletions
diff --git a/tests/unit/tabs/tabs.html b/tests/unit/tabs/tabs.html index 3d1c78040..c800894ff 100644 --- a/tests/unit/tabs/tabs.html +++ b/tests/unit/tabs/tabs.html @@ -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> diff --git a/tests/unit/tabs/tabs_core.js b/tests/unit/tabs/tabs_core.js index 25e54c3ee..30d58c254 100644 --- a/tests/unit/tabs/tabs_core.js +++ b/tests/unit/tabs/tabs_core.js @@ -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 }); diff --git a/tests/unit/tabs/tabs_deprecated.html b/tests/unit/tabs/tabs_deprecated.html index b50cebebc..54e0c39d6 100644 --- a/tests/unit/tabs/tabs_deprecated.html +++ b/tests/unit/tabs/tabs_deprecated.html @@ -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> diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js index c6549fd50..c3116989e 100644 --- a/tests/unit/tabs/tabs_deprecated.js +++ b/tests/unit/tabs/tabs_deprecated.js @@ -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() { diff --git a/tests/unit/tabs/tabs_events.js b/tests/unit/tabs/tabs_events.js index 2e54407de..28925a2b9 100644 --- a/tests/unit/tabs/tabs_events.js +++ b/tests/unit/tabs/tabs_events.js @@ -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" ); }); |