source: frontend/node_modules/eslint-plugin-jsx-a11y/__tests__/src/util/isInteractiveRole-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.4 KB
Line 
1import test from 'tape';
2import { elementType } from 'jsx-ast-utils';
3
4import isInteractiveRole from '../../../src/util/isInteractiveRole';
5import {
6 genElementSymbol,
7 genInteractiveRoleElements,
8 genNonInteractiveRoleElements,
9} from '../../../__mocks__/genInteractives';
10
11test('isInteractiveRole', (t) => {
12 t.equal(
13 isInteractiveRole(undefined, []),
14 false,
15 'identifies JSX Components (no tagName) as interactive role 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 isInteractiveRole(
24 elementType(openingElement),
25 attributes,
26 ),
27 false,
28 `does NOT identify \`${genElementSymbol(openingElement)}\` as an interactive role element`,
29 );
30 });
31
32 st.end();
33 });
34
35 t.equal(
36 isInteractiveRole('div', []),
37 false,
38 'does NOT identify elements without a role as 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 isInteractiveRole(
47 elementType(openingElement),
48 attributes,
49 ),
50 true,
51 `identifies \`${genElementSymbol(openingElement)}\` as an 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.