isAbstractRole-test.js
1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* eslint-env mocha */
import expect from 'expect';
import { elementType } from 'jsx-ast-utils';
import isAbstractRole from '../../../src/util/isAbstractRole';
import {
genElementSymbol,
genAbstractRoleElements,
genNonAbstractRoleElements,
} from '../../../__mocks__/genInteractives';
describe('isAbstractRole', () => {
describe('JSX Components (no tagName)', () => {
it('should NOT identify them as abstract role elements', () => {
expect(isAbstractRole(undefined, []))
.toBe(false);
});
});
describe('elements with an abstract role', () => {
genAbstractRoleElements().forEach(({ openingElement }) => {
const { attributes } = openingElement;
it(`should identify \`${genElementSymbol(openingElement)}\` as an abstract role element`, () => {
expect(isAbstractRole(
elementType(openingElement),
attributes,
)).toBe(true);
});
});
});
describe('elements with a non-abstract role', () => {
genNonAbstractRoleElements().forEach(({ openingElement }) => {
const { attributes } = openingElement;
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as an abstract role element`, () => {
expect(isAbstractRole(
elementType(openingElement),
attributes,
)).toBe(false);
});
});
});
});