Add tests for default tabpanel hidden states

This commit is contained in:
conzett 2011-11-22 21:03:32 -05:00
parent 8aa95004fc
commit 2cd63df1b7
2 changed files with 29 additions and 4 deletions

View File

@ -75,12 +75,14 @@
}); });
var activeClass = this.options.activeClass;
$(tabs).click(function() { $(tabs).click(function() {
var controls = $(this).attr('aria-controls'); var controls = $(this).attr('aria-controls');
$(this).siblings().attr('aria-selected', 'false').removeClass(this.options.activeClass); $(this).siblings().attr('aria-selected', 'false').removeClass(activeClass);
$(this).attr('aria-selected', 'true').addClass(this.options.activeClass); $(this).attr('aria-selected', 'true').addClass(activeClass);
$(tabPanels).attr('aria-hidden', 'true').css('display', 'none').removeClass(this.options.activeClass); $(tabPanels).attr('aria-hidden', 'true').css('display', 'none').removeClass(activeClass);
$(tabPanels).filter('#' + controls).attr('aria-hidden', 'false').css('display', 'block').addClass(this.options.activeClass); $(tabPanels).filter('#' + controls).attr('aria-hidden', 'false').css('display', 'block').addClass(activeClass);
}); });
}; };

View File

@ -225,4 +225,27 @@ $(document).ready(function () {
}); });
test("Initialization should set display correctly", 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) {
if(index != 0){
ok($(this).is(':hidden'),
'Expect tabpanel at position ' + index + ' to be hidden');
}else{
ok($(this).not(':hidden'),
'Expect tabpanel at position ' + index + ' to not be hidden');
}
});
});
}); });