source: frontend/node_modules/eslint-plugin-jsx-a11y/__tests__/src/util/isNonInteractiveRole-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.5 KB
Line 
1import test from 'tape';
2import { elementType } from 'jsx-ast-utils';
3
4import isNonInteractiveRole from '../../../src/util/isNonInteractiveRole';
5import {
6 genElementSymbol,
7 genInteractiveRoleElements,
8 genNonInteractiveRoleElements,
9} from '../../../__mocks__/genInteractives';
10
11test('isNonInteractiveRole', (t) => {
12 t.equal(
13 isNonInteractiveRole(undefined, []),
14 false,
15 'identifies JSX Components (no tagName) as non-interactive elements',
16 );
17
18 t.test('elements with a non-interactive role', (st) => {
19 genNonInteractiveRoleElements().forEach(({ openingElement }) => {
20 const { attributes } = openingElement;
21
22 st.equal(
23 isNonInteractiveRole(
24 elementType(openingElement),
25 attributes,
26 ),
27 true,
28 `identifies \`${genElementSymbol(openingElement)}\` as a non-interactive role element`,
29 );
30 });
31
32 st.end();
33 });
34
35 t.equal(
36 isNonInteractiveRole('div', []),
37 false,
38 'does NOT identify elements without a role as non-interactive role elements',
39 );
40
41 t.test('elements with an interactive role', (st) => {
42 genInteractiveRoleElements().forEach(({ openingElement }) => {
43 const { attributes } = openingElement;
44
45 st.equal(
46 isNonInteractiveRole(
47 elementType(openingElement),
48 attributes,
49 ),
50 false,
51 `does NOT identify \`${genElementSymbol(openingElement)}\` as a non-interactive role element`,
52 );
53 });
54
55 st.end();
56 });
57
58 t.end();
59});
Note: See TracBrowser for help on using the repository browser.