-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinserted-into-focus-order-matches.js
More file actions
50 lines (42 loc) · 1.56 KB
/
inserted-into-focus-order-matches.js
File metadata and controls
50 lines (42 loc) · 1.56 KB
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
describe('inserted-into-focus-order-matches', function () {
'use strict';
const fixture = document.getElementById('fixture');
const flatTreeSetup = axe.testUtils.flatTreeSetup;
let rule;
beforeEach(function () {
rule = axe.utils.getRule('focus-order-semantics');
});
afterEach(function () {
fixture.innerHTML = '';
});
it('should return true for a non-focusable element with tabindex > -1', function () {
fixture.innerHTML = '<div tabindex="0"></div>';
flatTreeSetup(fixture);
const node = fixture.firstChild;
assert.isTrue(rule.matches(node));
});
it('should return false for a non-focusable element with tabindex == -1', function () {
fixture.innerHTML = '<div tabindex="-1"></div>';
flatTreeSetup(fixture);
const node = fixture.firstChild;
assert.isFalse(rule.matches(node));
});
it('should return false for a native focusable element with tabindex > 0', function () {
fixture.innerHTML = '<button tabindex="0"></button>';
flatTreeSetup(fixture);
const node = fixture.firstChild;
assert.isFalse(rule.matches(node));
});
it('should return false for a native focusable element with no tabindex', function () {
fixture.innerHTML = '<a href="#"></a>';
flatTreeSetup(fixture);
const node = fixture.firstChild;
assert.isFalse(rule.matches(node));
});
it('should return false for non-numeric tabindex value', function () {
fixture.innerHTML = '<div tabindex="abc"></div>';
flatTreeSetup(fixture);
const node = fixture.firstChild;
assert.isFalse(rule.matches(node));
});
});