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