source: frontend/node_modules/eslint-plugin-jsx-a11y/__tests__/src/util/isSemanticRoleElement-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.6 KB
Line 
1import test from 'tape';
2
3import isSemanticRoleElement from '../../../src/util/isSemanticRoleElement';
4import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
5
6test('isSemanticRoleElement', (t) => {
7 t.equal(
8 isSemanticRoleElement('input', [
9 JSXAttributeMock('type', 'checkbox'),
10 JSXAttributeMock('role', 'switch'),
11 ]),
12 true,
13 'identifies semantic role elements',
14 );
15
16 t.test('rejects non-semantics role elements', (st) => {
17 st.equal(
18 isSemanticRoleElement('input', [
19 JSXAttributeMock('type', 'radio'),
20 JSXAttributeMock('role', 'switch'),
21 ]),
22 false,
23 );
24
25 st.equal(
26 isSemanticRoleElement('input', [
27 JSXAttributeMock('type', 'text'),
28 JSXAttributeMock('role', 'combobox'),
29 ]),
30 false,
31 );
32
33 st.equal(
34 isSemanticRoleElement('button', [
35 JSXAttributeMock('role', 'switch'),
36 JSXAttributeMock('aria-pressed', 'true'),
37 ]),
38 false,
39 );
40
41 st.equal(
42 isSemanticRoleElement('input', [
43 JSXAttributeMock('role', 'switch'),
44 ]),
45 false,
46 );
47
48 st.end();
49 });
50
51 t.doesNotThrow(
52 () => {
53 isSemanticRoleElement('input', [
54 JSXAttributeMock('type', 'checkbox'),
55 JSXAttributeMock('role', 'checkbox'),
56 JSXAttributeMock('aria-checked', 'false'),
57 JSXAttributeMock('aria-labelledby', 'foo'),
58 JSXAttributeMock('tabindex', '0'),
59 {
60 type: 'JSXSpreadAttribute',
61 argument: {
62 type: 'Identifier',
63 name: 'props',
64 },
65 },
66 ]);
67 },
68 'does not throw on JSXSpreadAttribute',
69 );
70
71 t.end();
72});
Note: See TracBrowser for help on using the repository browser.