source: frontend/node_modules/eslint-plugin-jsx-a11y/__tests__/src/util/isNonInteractiveElement-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: 2.5 KB
Line 
1import test from 'tape';
2import { elementType } from 'jsx-ast-utils';
3
4import isNonInteractiveElement from '../../../src/util/isNonInteractiveElement';
5import {
6 genElementSymbol,
7 genIndeterminantInteractiveElements,
8 genInteractiveElements,
9 genInteractiveRoleElements,
10 genNonInteractiveElements,
11 genNonInteractiveRoleElements,
12} from '../../../__mocks__/genInteractives';
13
14test('isNonInteractiveElement', (t) => {
15 t.equal(
16 isNonInteractiveElement(undefined, []),
17 false,
18 'identifies JSX Components (no tagName) as non-interactive elements',
19 );
20
21 t.test('non-interactive elements', (st) => {
22 genNonInteractiveElements().forEach(({ openingElement }) => {
23 st.equal(
24 isNonInteractiveElement(
25 elementType(openingElement),
26 openingElement.attributes,
27 ),
28 true,
29 `identifies \`${genElementSymbol(openingElement)}\` as a non-interactive element`,
30 );
31 });
32
33 st.end();
34 });
35
36 t.test('non-interactive role elements', (st) => {
37 genNonInteractiveRoleElements().forEach(({ openingElement }) => {
38 st.equal(
39 isNonInteractiveElement(
40 elementType(openingElement),
41 openingElement.attributes,
42 ),
43 false,
44 `identifies \`${genElementSymbol(openingElement)}\` as a non-interactive element`,
45 );
46 });
47
48 st.end();
49 });
50
51 t.test('interactive elements', (st) => {
52 genInteractiveElements().forEach(({ openingElement }) => {
53 st.equal(
54 isNonInteractiveElement(
55 elementType(openingElement),
56 openingElement.attributes,
57 ),
58 false,
59 `identifies \`${genElementSymbol(openingElement)}\` as a non-interactive element`,
60 );
61 });
62
63 st.end();
64 });
65
66 t.test('interactive role elements', (st) => {
67 genInteractiveRoleElements().forEach(({ openingElement }) => {
68 st.equal(
69 isNonInteractiveElement(
70 elementType(openingElement),
71 openingElement.attributes,
72 ),
73 false,
74 `identifies \`${genElementSymbol(openingElement)}\` as a non-interactive element`,
75 );
76 });
77
78 st.end();
79 });
80
81 t.test('indeterminate elements', (st) => {
82 genIndeterminantInteractiveElements().forEach(({ openingElement }) => {
83 st.equal(
84 isNonInteractiveElement(
85 elementType(openingElement),
86 openingElement.attributes,
87 ),
88 false,
89 `identifies \`${genElementSymbol(openingElement)}\` as a non-interactive element`,
90 );
91 });
92
93 st.end();
94 });
95
96 t.end();
97});
Note: See TracBrowser for help on using the repository browser.