|
| 1 | +describe('layout-table-matches', function () { |
| 2 | + 'use strict'; |
| 3 | + |
| 4 | + var fixture = document.getElementById('fixture'); |
| 5 | + var fixtureSetup = axe.testUtils.fixtureSetup; |
| 6 | + var rule; |
| 7 | + |
| 8 | + beforeEach(function () { |
| 9 | + rule = axe._audit.rules.find(function (rule) { |
| 10 | + return rule.id === 'layout-table'; |
| 11 | + }); |
| 12 | + }); |
| 13 | + |
| 14 | + afterEach(function () { |
| 15 | + fixture.innerHTML = ''; |
| 16 | + }); |
| 17 | + |
| 18 | + it('returns false for element that is not focusable and has presentation role', function () { |
| 19 | + fixtureSetup('<table role="presentation"></table>'); |
| 20 | + var target = fixture.querySelector('table'); |
| 21 | + |
| 22 | + assert.isFalse(rule.matches(target)); |
| 23 | + }); |
| 24 | + |
| 25 | + it('returns false for element that is not focusable and has none role', function () { |
| 26 | + fixtureSetup('<table role="none"></table>'); |
| 27 | + var target = fixture.querySelector('table'); |
| 28 | + |
| 29 | + assert.isFalse(rule.matches(target)); |
| 30 | + }); |
| 31 | + |
| 32 | + it('returns trie for element that is a table without presentation/none role', function () { |
| 33 | + fixtureSetup('<table></table>'); |
| 34 | + var target = fixture.querySelector('table'); |
| 35 | + |
| 36 | + assert.isTrue(rule.matches(target)); |
| 37 | + }); |
| 38 | + |
| 39 | + it('returns true for element that is focusable and has none role', function () { |
| 40 | + fixtureSetup('<table role="none" tabindex="0"></table>'); |
| 41 | + var target = fixture.querySelector('table'); |
| 42 | + |
| 43 | + assert.isTrue(rule.matches(target)); |
| 44 | + }); |
| 45 | + |
| 46 | + it('returns true for element that is focusable and has presentation role', function () { |
| 47 | + fixtureSetup('<table role="presentation" tabindex="0"></table>'); |
| 48 | + var target = fixture.querySelector('table'); |
| 49 | + |
| 50 | + assert.isTrue(rule.matches(target)); |
| 51 | + }); |
| 52 | +}); |
0 commit comments