-
Notifications
You must be signed in to change notification settings - Fork 800
/
Copy patharia-prohibited-attr.js
61 lines (53 loc) · 1.58 KB
/
aria-prohibited-attr.js
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
describe('aria-prohibited-attr virtual-rule', () => {
it('should pass for required attributes', () => {
const results = axe.runVirtualRule('aria-prohibited-attr', {
nodeName: 'div',
attributes: {
role: 'checkbox',
'aria-checked': true
}
});
assert.lengthOf(results.passes, 1);
assert.lengthOf(results.violations, 0);
assert.lengthOf(results.incomplete, 0);
});
it('should pass for allowed attributes', () => {
const results = axe.runVirtualRule('aria-prohibited-attr', {
nodeName: 'div',
attributes: {
role: 'radio',
'aria-required': true,
'aria-checked': true
}
});
assert.lengthOf(results.passes, 1);
assert.lengthOf(results.violations, 0);
assert.lengthOf(results.incomplete, 0);
});
it('should pass for invalid attributes', () => {
const results = axe.runVirtualRule('aria-prohibited-attr', {
nodeName: 'div',
attributes: {
role: 'dialog',
'aria-cats': true
}
});
assert.lengthOf(results.passes, 1);
assert.lengthOf(results.violations, 0);
assert.lengthOf(results.incomplete, 0);
});
it('should fail for prohibited attributes', () => {
const vNode = new axe.SerialVirtualNode({
nodeName: 'div',
attributes: {
role: 'code',
'aria-label': 'foo'
}
});
vNode.children = [];
const results = axe.runVirtualRule('aria-prohibited-attr', vNode);
assert.lengthOf(results.passes, 0);
assert.lengthOf(results.violations, 1);
assert.lengthOf(results.incomplete, 0);
});
});