|
| 1 | +describe('aria-roledescription', function() { |
| 2 | + 'use strict'; |
| 3 | + |
| 4 | + var fixture = document.getElementById('fixture'); |
| 5 | + var checkContext = axe.testUtils.MockCheckContext(); |
| 6 | + |
| 7 | + afterEach(function() { |
| 8 | + fixture.innerHTML = ''; |
| 9 | + checkContext.reset(); |
| 10 | + }); |
| 11 | + |
| 12 | + it('returns true for elements with an implicit supported role', function() { |
| 13 | + fixture.innerHTML = |
| 14 | + '<button aria-roledescription="Awesome Button">Click</button>'; |
| 15 | + var actual = checks['aria-roledescription'].evaluate.call( |
| 16 | + checkContext, |
| 17 | + fixture.firstChild, |
| 18 | + { |
| 19 | + supportedRoles: ['button'] |
| 20 | + } |
| 21 | + ); |
| 22 | + assert.equal(actual, true); |
| 23 | + assert.isNull(checkContext._data, null); |
| 24 | + }); |
| 25 | + |
| 26 | + it('returns true for elements with an explicit supported role', function() { |
| 27 | + fixture.innerHTML = |
| 28 | + '<div role="radio" aria-roledescription="Awesome Radio">Click</div>'; |
| 29 | + var actual = checks['aria-roledescription'].evaluate.call( |
| 30 | + checkContext, |
| 31 | + fixture.firstChild, |
| 32 | + { |
| 33 | + supportedRoles: ['radio'] |
| 34 | + } |
| 35 | + ); |
| 36 | + assert.equal(actual, true); |
| 37 | + assert.isNull(checkContext._data, null); |
| 38 | + }); |
| 39 | + |
| 40 | + it('returns undefined for elements with an unsupported role', function() { |
| 41 | + fixture.innerHTML = |
| 42 | + '<div role="main" aria-roledescription="Awesome Main">The main element</div>'; |
| 43 | + var actual = checks['aria-roledescription'].evaluate.call( |
| 44 | + checkContext, |
| 45 | + fixture.firstChild |
| 46 | + ); |
| 47 | + assert.equal(actual, undefined); |
| 48 | + assert.isNull(checkContext._data, null); |
| 49 | + }); |
| 50 | + |
| 51 | + it('returns false for elements without role', function() { |
| 52 | + fixture.innerHTML = |
| 53 | + '<div aria-roledescription="Awesome Main">The main element</div>'; |
| 54 | + var actual = checks['aria-roledescription'].evaluate.call( |
| 55 | + checkContext, |
| 56 | + fixture.firstChild |
| 57 | + ); |
| 58 | + assert.equal(actual, false); |
| 59 | + assert.isNull(checkContext._data, null); |
| 60 | + }); |
| 61 | + |
| 62 | + it('returns false for elements with role=presentation', function() { |
| 63 | + fixture.innerHTML = |
| 64 | + '<div role="presentation" aria-roledescription="Awesome Main">The main element</div>'; |
| 65 | + var actual = checks['aria-roledescription'].evaluate.call( |
| 66 | + checkContext, |
| 67 | + fixture.firstChild |
| 68 | + ); |
| 69 | + assert.equal(actual, false); |
| 70 | + assert.isNull(checkContext._data, null); |
| 71 | + }); |
| 72 | + |
| 73 | + it('returns false for elements with role=none', function() { |
| 74 | + fixture.innerHTML = |
| 75 | + '<div role="none" aria-roledescription="Awesome Main">The main element</div>'; |
| 76 | + var actual = checks['aria-roledescription'].evaluate.call( |
| 77 | + checkContext, |
| 78 | + fixture.firstChild |
| 79 | + ); |
| 80 | + assert.equal(actual, false); |
| 81 | + assert.isNull(checkContext._data, null); |
| 82 | + }); |
| 83 | +}); |
0 commit comments