source: frontend/node_modules/eslint-plugin-jsx-a11y/__tests__/src/rules/no-aria-hidden-on-focusable-test.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 2 weeks ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/**
2 * @fileoverview Enforce `aria-hidden="true"` is not used on focusable elements.
3 * @author Kate Higa
4*/
5
6// -----------------------------------------------------------------------------
7// Requirements
8// -----------------------------------------------------------------------------
9
10import { RuleTester } from 'eslint';
11import parserOptionsMapper from '../../__util__/parserOptionsMapper';
12import parsers from '../../__util__/helpers/parsers';
13import rule from '../../../src/rules/no-aria-hidden-on-focusable';
14
15// -----------------------------------------------------------------------------
16// Tests
17// -----------------------------------------------------------------------------
18
19const ruleTester = new RuleTester();
20
21const expectedError = {
22 message: 'aria-hidden="true" must not be set on focusable elements.',
23 type: 'JSXOpeningElement',
24};
25
26ruleTester.run('no-aria-hidden-on-focusable', rule, {
27 valid: parsers.all([].concat(
28 { code: '<div aria-hidden="true" />;' },
29 { code: '<div onClick={() => void 0} aria-hidden="true" />;' },
30 { code: '<img aria-hidden="true" />' },
31 { code: '<a aria-hidden="false" href="#" />' },
32 { code: '<button aria-hidden="true" tabIndex="-1" />' },
33 { code: '<button />' },
34 { code: '<a href="/" />' },
35 )).map(parserOptionsMapper),
36 invalid: parsers.all([].concat(
37 { code: '<div aria-hidden="true" tabIndex="0" />;', errors: [expectedError] },
38 { code: '<input aria-hidden="true" />;', errors: [expectedError] },
39 { code: '<a href="/" aria-hidden="true" />', errors: [expectedError] },
40 { code: '<button aria-hidden="true" />', errors: [expectedError] },
41 { code: '<textarea aria-hidden="true" />', errors: [expectedError] },
42 { code: '<p tabindex="0" aria-hidden="true">text</p>;', errors: [expectedError] },
43 )).map(parserOptionsMapper),
44});
Note: See TracBrowser for help on using the repository browser.