forked from dequelabs/axe-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata-table-matches.js
56 lines (46 loc) · 1.6 KB
/
data-table-matches.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
describe('data-table-matches', function() {
'use strict';
var fixture = document.getElementById('fixture');
var fixtureSetup = axe.testUtils.fixtureSetup;
var rule;
beforeEach(function() {
rule = axe.utils.getRule('th-has-data-cells');
});
afterEach(function() {
fixture.innerHTML = '';
});
it('is a function', function() {
assert.isFunction(rule.matches);
});
it('should return false if table has role="presentation"', function() {
fixtureSetup(
'<table role="presentation" id="target">' +
' <tr> <th>hi</th> <td></td> </tr>' +
' <tr> <th>hi</th> <td></td> </tr>' +
'</table>'
);
var 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"', function() {
fixtureSetup(
'<table role="none" id="target">' +
' <tr> <th>hi</th> <td></td> </tr>' +
' <tr> <th>hi</th> <td></td> </tr>' +
'</table>'
);
var 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', function() {
fixtureSetup(
'<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>'
);
var vNode = axe.utils.querySelectorAll(axe._tree[0], 'table')[0];
assert.isTrue(rule.matches(vNode.actualNode, vNode));
});
});