forked from dequelabs/axe-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata-table-matches.js
More file actions
76 lines (66 loc) · 1.74 KB
/
Copy pathdata-table-matches.js
File metadata and controls
76 lines (66 loc) · 1.74 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
describe('data-table-matches', () => {
const html = axe.testUtils.html;
const fixture = document.getElementById('fixture');
const fixtureSetup = axe.testUtils.fixtureSetup;
let rule;
beforeEach(() => {
rule = axe.utils.getRule('th-has-data-cells');
});
afterEach(() => {
fixture.innerHTML = '';
});
it('is a function', () => {
assert.isFunction(rule.matches);
});
it('should return false if table has role="presentation"', () => {
fixtureSetup(html`
<table role="presentation" id="target">
<tr>
<th>hi</th>
<td></td>
</tr>
<tr>
<th>hi</th>
<td></td>
</tr>
</table>
`);
const vNode = axe.utils.querySelectorAll(axe._tree[0], 'table')[0];
assert.isFalse(rule.matches(vNode.actualNode, vNode));
});
it('should return false if table has role="none"', () => {
fixtureSetup(html`
<table role="none" id="target">
<tr>
<th>hi</th>
<td></td>
</tr>
<tr>
<th>hi</th>
<td></td>
</tr>
</table>
`);
const vNode = axe.utils.querySelectorAll(axe._tree[0], 'table')[0];
assert.isFalse(rule.matches(vNode.actualNode, vNode));
});
it('should return true if table is a data table', () => {
fixtureSetup(html`
<table id="target">
<caption>
Table caption
</caption>
<tr>
<th scope="col">Heading 1</th>
<th scope="col">Heading 2</th>
</tr>
<tr>
<td>Thing 1</td>
<td>Thing 2</td>
</tr>
</table>
`);
const vNode = axe.utils.querySelectorAll(axe._tree[0], 'table')[0];
assert.isTrue(rule.matches(vNode.actualNode, vNode));
});
});