|
1 | 1 | describe('empty-table-header virtual-rule', function () {
|
2 |
| - it('should incomplete when children are missing', function () { |
| 2 | + it('should fail when children contain no visible text', function () { |
3 | 3 | var thNode = new axe.SerialVirtualNode({
|
4 | 4 | nodeName: 'th'
|
5 | 5 | });
|
6 | 6 | thNode.children = [];
|
7 | 7 |
|
8 | 8 | var results = axe.runVirtualRule('empty-table-header', thNode);
|
9 | 9 |
|
| 10 | + assert.lengthOf(results.passes, 0); |
| 11 | + assert.lengthOf(results.violations, 1); |
| 12 | + assert.lengthOf(results.incomplete, 0); |
| 13 | + }); |
| 14 | + |
| 15 | + it('should incomplete when children are missing', function () { |
| 16 | + var thNode = new axe.SerialVirtualNode({ |
| 17 | + nodeName: 'th' |
| 18 | + }); |
| 19 | + |
| 20 | + var results = axe.runVirtualRule('empty-table-header', thNode); |
| 21 | + |
10 | 22 | assert.lengthOf(results.passes, 0);
|
11 | 23 | assert.lengthOf(results.violations, 0);
|
12 | 24 | assert.lengthOf(results.incomplete, 1);
|
13 | 25 | });
|
14 | 26 |
|
| 27 | + it('should fail for role=rowheader', function () { |
| 28 | + var vNode = new axe.SerialVirtualNode({ |
| 29 | + nodeName: 'div', |
| 30 | + attributes: { |
| 31 | + role: 'rowheader' |
| 32 | + } |
| 33 | + }); |
| 34 | + vNode.children = []; |
| 35 | + |
| 36 | + var results = axe.runVirtualRule('empty-table-header', vNode); |
| 37 | + |
| 38 | + assert.lengthOf(results.passes, 0); |
| 39 | + assert.lengthOf(results.violations, 1); |
| 40 | + assert.lengthOf(results.incomplete, 0); |
| 41 | + }); |
| 42 | + |
| 43 | + it('should fail for role=columnheader', function () { |
| 44 | + var vNode = new axe.SerialVirtualNode({ |
| 45 | + nodeName: 'div', |
| 46 | + attributes: { |
| 47 | + role: 'columnheader' |
| 48 | + } |
| 49 | + }); |
| 50 | + vNode.children = []; |
| 51 | + |
| 52 | + var results = axe.runVirtualRule('empty-table-header', vNode); |
| 53 | + |
| 54 | + assert.lengthOf(results.passes, 0); |
| 55 | + assert.lengthOf(results.violations, 1); |
| 56 | + assert.lengthOf(results.incomplete, 0); |
| 57 | + }); |
| 58 | + |
15 | 59 | it('should pass with a table header', function () {
|
16 | 60 | var tableNode = new axe.SerialVirtualNode({
|
17 | 61 | nodeName: 'table'
|
@@ -137,19 +181,33 @@ describe('empty-table-header virtual-rule', function () {
|
137 | 181 | assert.lengthOf(results.incomplete, 0);
|
138 | 182 | });
|
139 | 183 |
|
140 |
| - it('should fail if table header has no child nodes', function () { |
141 |
| - var node = new axe.SerialVirtualNode({ |
| 184 | + it('should be inapplicable when the th has role of cell', function () { |
| 185 | + var table = new axe.SerialVirtualNode({ |
| 186 | + nodeName: 'table' |
| 187 | + }); |
| 188 | + |
| 189 | + var tr = new axe.SerialVirtualNode({ |
| 190 | + nodeName: 'tr' |
| 191 | + }); |
| 192 | + |
| 193 | + var th = new axe.SerialVirtualNode({ |
142 | 194 | nodeName: 'th',
|
143 | 195 | attributes: {
|
144 |
| - role: 'rowheader' |
| 196 | + role: 'cell' |
145 | 197 | }
|
146 | 198 | });
|
147 |
| - node.children = []; |
148 | 199 |
|
149 |
| - var results = axe.runVirtualRule('empty-table-header', node); |
| 200 | + tr.children = [th]; |
| 201 | + tr.parent = table; |
| 202 | + th.parent = tr; |
| 203 | + th.children = []; |
| 204 | + table.children = [tr]; |
| 205 | + |
| 206 | + var results = axe.runVirtualRule('empty-table-header', th); |
150 | 207 |
|
151 | 208 | assert.lengthOf(results.passes, 0);
|
152 |
| - assert.lengthOf(results.violations, 1); |
| 209 | + assert.lengthOf(results.violations, 0); |
153 | 210 | assert.lengthOf(results.incomplete, 0);
|
| 211 | + assert.lengthOf(results.inapplicable, 1); |
154 | 212 | });
|
155 | 213 | });
|
0 commit comments