|
| 1 | +describe('aria-valid-attr-value', () => { |
| 2 | + 'use strict'; |
| 3 | + |
| 4 | + const checkContext = axe.testUtils.MockCheckContext(); |
| 5 | + const checkSetup = axe.testUtils.checkSetup; |
| 6 | + const checkEvaluate = axe.testUtils.getCheckEvaluate('aria-valid-attr-value'); |
| 7 | + |
| 8 | + afterEach(() => { |
| 9 | + checkContext.reset(); |
| 10 | + }); |
| 11 | + |
| 12 | + it('emits the flagged aria-current attribute in reviewPayload.visualHelperData', () => { |
| 13 | + const params = checkSetup( |
| 14 | + '<div id="target" aria-current="active">Contents</div>' |
| 15 | + ); |
| 16 | + assert.isUndefined(checkEvaluate.apply(checkContext, params)); |
| 17 | + assert.equal(checkContext._data.messageKey, 'ariaCurrent'); |
| 18 | + assert.equal(checkContext._data.needsReview, 'aria-current="active"'); |
| 19 | + assert.deepEqual(checkContext._data.reviewPayload, { |
| 20 | + visualHelperData: { ariaAttribute: 'aria-current="active"' } |
| 21 | + }); |
| 22 | + }); |
| 23 | + |
| 24 | + it('emits the flagged aria-labelledby attribute in reviewPayload.visualHelperData', () => { |
| 25 | + const params = checkSetup( |
| 26 | + '<div id="target" aria-labelledby="missing-id">Contents</div>' |
| 27 | + ); |
| 28 | + assert.isUndefined(checkEvaluate.apply(checkContext, params)); |
| 29 | + assert.equal( |
| 30 | + checkContext._data.needsReview, |
| 31 | + 'aria-labelledby="missing-id"' |
| 32 | + ); |
| 33 | + assert.deepEqual(checkContext._data.reviewPayload, { |
| 34 | + visualHelperData: { ariaAttribute: 'aria-labelledby="missing-id"' } |
| 35 | + }); |
| 36 | + }); |
| 37 | + |
| 38 | + it('does not add a reviewPayload on the invalid-value (violation) path', () => { |
| 39 | + const params = checkSetup( |
| 40 | + '<div id="target" role="checkbox" aria-checked="foo">Contents</div>' |
| 41 | + ); |
| 42 | + assert.isFalse(checkEvaluate.apply(checkContext, params)); |
| 43 | + assert.isArray(checkContext._data); |
| 44 | + assert.notProperty(checkContext._data, 'reviewPayload'); |
| 45 | + }); |
| 46 | +}); |
0 commit comments