isNonInteractiveElement-test.js
2.53 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* eslint-env mocha */
import expect from 'expect';
import { elementType } from 'jsx-ast-utils';
import isNonInteractiveElement from '../../../src/util/isNonInteractiveElement';
import {
genElementSymbol,
genIndeterminantInteractiveElements,
genInteractiveElements,
genInteractiveRoleElements,
genNonInteractiveElements,
genNonInteractiveRoleElements,
} from '../../../__mocks__/genInteractives';
describe('isNonInteractiveElement', () => {
describe('JSX Components (no tagName)', () => {
it('should identify them as interactive elements', () => {
expect(isNonInteractiveElement(undefined, []))
.toBe(false);
});
});
describe('non-interactive elements', () => {
genNonInteractiveElements().forEach(({ openingElement }) => {
it(`should identify \`${genElementSymbol(openingElement)}\` as a non-interactive element`, () => {
expect(isNonInteractiveElement(
elementType(openingElement),
openingElement.attributes,
)).toBe(true);
});
});
});
describe('non-interactive role elements', () => {
genNonInteractiveRoleElements().forEach(({ openingElement }) => {
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as a non-interactive element`, () => {
expect(isNonInteractiveElement(
elementType(openingElement),
openingElement.attributes,
)).toBe(false);
});
});
});
describe('interactive elements', () => {
genInteractiveElements().forEach(({ openingElement }) => {
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as a non-interactive element`, () => {
expect(isNonInteractiveElement(
elementType(openingElement),
openingElement.attributes,
)).toBe(false);
});
});
});
describe('interactive role elements', () => {
genInteractiveRoleElements().forEach(({ openingElement }) => {
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as a non-interactive element`, () => {
expect(isNonInteractiveElement(
elementType(openingElement),
openingElement.attributes,
)).toBe(false);
});
});
});
describe('indeterminate elements', () => {
genIndeterminantInteractiveElements().forEach(({ openingElement }) => {
it(`should NOT identify \`${openingElement.name.name}\` as a non-interactive element`, () => {
expect(isNonInteractiveElement(
elementType(openingElement),
openingElement.attributes,
)).toBe(false);
});
});
});
});