Skip to content

Commit 47a427e

Browse files
committed
Tabs: ARIA tests.
1 parent 48588d3 commit 47a427e

File tree

1 file changed

+57
-2
lines changed

1 file changed

+57
-2
lines changed

tests/unit/tabs/tabs_core.js

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,63 @@ test( "aria-controls", function() {
6363
});
6464

6565
test( "accessibility", function() {
66-
// TODO: add tests
67-
expect( 0 );
66+
expect( 49 );
67+
var element = $( "#tabs1" ).tabs({
68+
active: 1,
69+
disabled: [ 2 ]
70+
}),
71+
tabs = element.find( ".ui-tabs-nav li" ),
72+
anchors = tabs.find( ".ui-tabs-anchor" ),
73+
panels = element.find( ".ui-tabs-panel" );
74+
75+
equal( element.find( ".ui-tabs-nav" ).attr( "role" ), "tablist", "tablist role" );
76+
tabs.each(function( index ) {
77+
var tab = tabs.eq( index ),
78+
anchor = anchors.eq( index ),
79+
anchorId = anchor.attr( "id" ),
80+
panel = panels.eq( index );
81+
equal( tab.attr( "role" ), "tab", "tab " + index + " role" );
82+
equal( tab.attr( "aria-labelledby" ), anchorId, "tab " + index + " aria-labelledby" );
83+
equal( anchor.attr( "role" ), "presentation", "anchor " + index + " role" );
84+
equal( anchor.attr( "tabindex" ), -1, "anchor " + index + " tabindex" );
85+
equal( panel.attr( "role" ), "tabpanel", "panel " + index + " role" );
86+
equal( panel.attr( "aria-labelledby" ), anchorId, "panel " + index + " aria-labelledby" );
87+
});
88+
89+
equal( tabs.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
90+
equal( tabs.eq( 1 ).attr( "tabindex" ), 0, "active tab has tabindex=0" );
91+
equal( tabs.eq( 1 ).attr( "aria-disabled" ), null, "enabled tab does not have aria-disabled" );
92+
equal( panels.eq( 1 ).attr( "aria-expanded" ), "true", "active panel has aria-expanded=true" );
93+
equal( panels.eq( 1 ).attr( "aria-hidden" ), "false", "active panel has aria-hidden=false" );
94+
equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
95+
equal( tabs.eq( 0 ).attr( "tabindex" ), -1, "inactive tab has tabindex=-1" );
96+
equal( tabs.eq( 0 ).attr( "aria-disabled" ), null, "enabled tab does not have aria-disabled" );
97+
equal( panels.eq( 0 ).attr( "aria-expanded" ), "false", "inactive panel has aria-expanded=false" );
98+
equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "inactive panel has aria-hidden=true" );
99+
equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
100+
equal( tabs.eq( 2 ).attr( "tabindex" ), -1, "inactive tab has tabindex=-1" );
101+
equal( tabs.eq( 2 ).attr( "aria-disabled" ), "true", "disabled tab has aria-disabled=true" );
102+
equal( panels.eq( 2 ).attr( "aria-expanded" ), "false", "inactive panel has aria-expanded=false" );
103+
equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "inactive panel has aria-hidden=true" );
104+
105+
element.tabs( "option", "active", 0 );
106+
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
107+
equal( tabs.eq( 0 ).attr( "tabindex" ), 0, "active tab has tabindex=0" );
108+
equal( tabs.eq( 0 ).attr( "aria-disabled" ), null, "enabled tab does not have aria-disabled" );
109+
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "active panel has aria-expanded=true" );
110+
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "active panel has aria-hidden=false" );
111+
equal( tabs.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
112+
equal( tabs.eq( 1 ).attr( "tabindex" ), -1, "inactive tab has tabindex=-1" );
113+
equal( tabs.eq( 1 ).attr( "aria-disabled" ), null, "enabled tab does not have aria-disabled" );
114+
equal( panels.eq( 1 ).attr( "aria-expanded" ), "false", "inactive panel has aria-expanded=false" );
115+
equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "inactive panel has aria-hidden=true" );
116+
equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
117+
equal( tabs.eq( 2 ).attr( "tabindex" ), -1, "inactive tab has tabindex=-1" );
118+
equal( tabs.eq( 2 ).attr( "aria-disabled" ), "true", "disabled tab has aria-disabled=true" );
119+
equal( panels.eq( 2 ).attr( "aria-expanded" ), "false", "inactive panel has aria-expanded=false" );
120+
equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "inactive panel has aria-hidden=true" );
121+
122+
// TODO: aria-live and aria-busy tests for ajax tabs
68123
});
69124

70125
test( "#3627 - Ajax tab with url containing a fragment identifier fails to load", function() {

0 commit comments

Comments
 (0)