2008-09-20 17:42:04 +00:00
|
|
|
/*
|
|
|
|
* core unit tests
|
|
|
|
*/
|
|
|
|
(function($) {
|
|
|
|
|
|
|
|
module("selectors");
|
|
|
|
|
|
|
|
test("tabbable - enabled elements", function() {
|
|
|
|
expect(10);
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-09-20 17:42:04 +00:00
|
|
|
ok( $('#input1-1').is(':tabbable'), 'input, no type');
|
|
|
|
ok( $('#input1-2').is(':tabbable'), 'input, type text');
|
|
|
|
ok( $('#input1-3').is(':tabbable'), 'input, type checkbox');
|
|
|
|
ok( $('#input1-4').is(':tabbable'), 'input, type radio');
|
|
|
|
ok( $('#input1-5').is(':tabbable'), 'input, type button');
|
|
|
|
ok(!$('#input1-6').is(':tabbable'), 'input, type hidden');
|
|
|
|
ok( $('#input1-7').is(':tabbable'), 'select');
|
|
|
|
ok( $('#input1-8').is(':tabbable'), 'textarea');
|
|
|
|
ok( $('#anchor1-1').is(':tabbable'), 'anchor with href');
|
|
|
|
ok(!$('#anchor1-2').is(':tabbable'), 'anchor without href');
|
|
|
|
});
|
|
|
|
|
|
|
|
test("tabbable - disabled elements", function() {
|
|
|
|
expect(8);
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-09-20 17:42:04 +00:00
|
|
|
ok(!$('#input2-1').is(':tabbable'), 'input, no type');
|
|
|
|
ok(!$('#input2-2').is(':tabbable'), 'input, type text');
|
|
|
|
ok(!$('#input2-3').is(':tabbable'), 'input, type checkbox');
|
|
|
|
ok(!$('#input2-4').is(':tabbable'), 'input, type radio');
|
|
|
|
ok(!$('#input2-5').is(':tabbable'), 'input, type button');
|
|
|
|
ok(!$('#input2-6').is(':tabbable'), 'input, type hidden');
|
|
|
|
ok(!$('#input2-7').is(':tabbable'), 'select');
|
|
|
|
ok(!$('#input2-8').is(':tabbable'), 'textarea');
|
|
|
|
});
|
|
|
|
|
|
|
|
test("tabbable - hidden styles", function() {
|
|
|
|
expect(6);
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-09-20 17:42:04 +00:00
|
|
|
ok(!$('#input3-1').is(':tabbable'), 'input, hidden wrapper - display: none');
|
|
|
|
ok(!$('#anchor3-1').is(':tabbable'), 'anchor, hidden wrapper - display: none');
|
|
|
|
ok(!$('#input3-2').is(':tabbable'), 'input, hidden wrapper - visibility: hidden');
|
|
|
|
ok(!$('#anchor3-2').is(':tabbable'), 'anchor, hidden wrapper - visibility: hidden');
|
|
|
|
ok(!$('#input3-3').is(':tabbable'), 'input, display: none');
|
|
|
|
ok(!$('#input3-4').is(':tabbable'), 'input, visibility: hidden');
|
|
|
|
});
|
|
|
|
|
|
|
|
test("tabbable - tabindex", function() {
|
|
|
|
expect(4);
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-09-20 17:42:04 +00:00
|
|
|
ok( $('#input4-1').is(':tabbable'), 'input, tabindex 0');
|
|
|
|
ok( $('#input4-2').is(':tabbable'), 'input, tabindex 10');
|
|
|
|
ok(!$('#input4-3').is(':tabbable'), 'input, tabindex -1');
|
|
|
|
ok(!$('#input4-4').is(':tabbable'), 'input, tabindex -50');
|
|
|
|
});
|
|
|
|
|
2008-11-07 13:49:23 +00:00
|
|
|
module('jQuery extensions');
|
|
|
|
|
|
|
|
test("attr - aria", function() {
|
2008-11-15 04:29:08 +00:00
|
|
|
expect(6);
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-11-15 04:29:08 +00:00
|
|
|
var el = $('#aria');
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-11-15 04:29:08 +00:00
|
|
|
ok(!el.attr('role'), 'role is empty via attr');
|
|
|
|
equals(el.attr('role', 'tablist').attr('role'), 'tablist', 'role is tablist');
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-11-15 04:29:08 +00:00
|
|
|
equals(el.attr('aria-expanded'), undefined, 'aria expanded is undefined');
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-11-15 04:29:08 +00:00
|
|
|
el.attr('aria-expanded', true);
|
|
|
|
equals(el.attr('aria-expanded'), 'true', 'aria expanded is true');
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-11-15 04:29:08 +00:00
|
|
|
el.removeAttr('aria-expanded');
|
|
|
|
equals(el.attr('aria-expanded'), undefined, 'aria expanded is undefined after removing');
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-11-15 04:29:08 +00:00
|
|
|
el.attr('aria-expanded', false);
|
|
|
|
equals(el.attr('aria-expanded'), 'false', 'aria expanded is false');
|
2008-09-22 15:47:41 +00:00
|
|
|
});
|
|
|
|
|
2008-09-20 17:42:04 +00:00
|
|
|
})(jQuery);
|