Add tests for aria-controls and aria-labeledby attribute generation
This commit is contained in:
parent
7779cb0506
commit
9afc75f2b1
@ -41,12 +41,24 @@
|
||||
$(this).attr('aria-selected', 'false');
|
||||
}
|
||||
|
||||
// add IDs to tabs
|
||||
|
||||
if(!id){
|
||||
$(this).attr('id', 'tab' + parseInt(index + 1));
|
||||
}
|
||||
|
||||
$(this).attr('role', 'tab');
|
||||
|
||||
});
|
||||
|
||||
$(tabPanels).each(function(index) {
|
||||
|
||||
var id = $(this).attr('id');
|
||||
|
||||
if(!id){
|
||||
$(this).attr('id', 'tabpanel' + parseInt(index + 1));
|
||||
}
|
||||
|
||||
$(this).attr('role', 'tabpanel');
|
||||
|
||||
});
|
||||
|
||||
// if there isn't already a selected tab, make the first one selected
|
||||
@ -55,18 +67,6 @@
|
||||
{
|
||||
$(tabs).first().attr('aria-selected', 'true');
|
||||
}
|
||||
|
||||
// add IDs to tab panels
|
||||
|
||||
$(tabPanels).each(function(index) {
|
||||
|
||||
var id = $(this).attr('id');
|
||||
|
||||
if(!id){
|
||||
$(this).attr('id', 'tabpanel' + parseInt(index + 1));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
@ -128,4 +128,36 @@ $(document).ready(function () {
|
||||
|
||||
});
|
||||
|
||||
test("Aria-controls attribute generation", function () {
|
||||
|
||||
var tabContainer = $('#qunit-fixture #tab-container');
|
||||
var tabList = $(tabContainer).find('> ul');
|
||||
var tabPanels = $(tabContainer).children().not('ul');
|
||||
var tabs = tabList.find('li');
|
||||
tabContainer.skeletonTabs();
|
||||
|
||||
$(tabs).each(function(index) {
|
||||
equals($(this).attr('aria-controls'),
|
||||
$(tabPanels[index]).attr('id'),
|
||||
'Expect tab at position ' + index + ' to match panel id at position ' + index);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test("Aria-labeledby attribute generation", function () {
|
||||
|
||||
var tabContainer = $('#qunit-fixture #tab-container');
|
||||
var tabList = $(tabContainer).find('> ul');
|
||||
var tabPanels = $(tabContainer).children().not('ul');
|
||||
var tabs = tabList.find('li');
|
||||
tabContainer.skeletonTabs();
|
||||
|
||||
$(tabPanels).each(function(index) {
|
||||
equals($(this).attr('aria-labeledby'),
|
||||
$(tabs[index]).attr('id'),
|
||||
'Expect tab at position ' + index + ' to match panel id at position ' + index);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in New Issue
Block a user