aboutsummaryrefslogtreecommitdiffstats
path: root/tests/core.js
blob: d4ec7937315a0f87aa70f3232277499e74859e5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 * core unit tests
 */
(function($) {

module("selectors");

test("tabbable - enabled elements", function() {
	expect(10);
	
	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);
	
	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);
	
	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);
	
	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');
});

test("aria", function() {
	expect(10);
	
	ok(!$('#aria').attr('role'), 'role is empty via attr');
	ok(!$('#aria').ariaRole(), 'role is empty via ariaRole');
	equals($('#aria').ariaRole('dialog').attr('role').replace(/^wairole:/, ""), 'dialog', 'role is dialog');
	equals($('#aria').ariaRole(), 'dialog', 'role is dialog');
	equals($('#aria').ariaRole('tablist').attr('role').replace(/^wairole:/, ""), 'tablist', 'role is tablist via attr');
	equals($('#aria').ariaRole(), 'tablist', 'role is tablist via ariaRole');
	ok(!$('#aria').attr('expanded'), 'state expanded absent via attr');
	ok(!$('#aria').ariaState('expanded'), 'state expanded absent via ariaState');
	equals($('#aria').ariaState('expanded', true).ariaState('expanded'), 'true', 'aria expanded is true');
	equals($('#aria').ariaState('expanded', false).ariaState('expanded'), 'false', 'aria expanded is false');
});

})(jQuery);