source: frontend/node_modules/eslint-plugin-jsx-a11y/__tests__/src/util/isDisabledElement-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.9 KB
Line 
1import test from 'tape';
2
3import isDisabledElement from '../../../src/util/isDisabledElement';
4import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
5
6test('isDisabledElement', (t) => {
7 t.test('HTML5', (st) => {
8 st.equal(
9 isDisabledElement([
10 JSXAttributeMock('disabled', 'disabled'),
11 ]),
12 true,
13 'identifies HTML5 disabled elements',
14 );
15
16 st.equal(
17 isDisabledElement([
18 JSXAttributeMock('disabled', null),
19 ]),
20 true,
21 'identifies HTML5 disabled elements with null as the value',
22 );
23
24 st.equal(
25 isDisabledElement([
26 JSXAttributeMock('disabled', undefined),
27 ]),
28 false,
29 'does not identify HTML5 disabled elements with undefined as the value',
30 );
31
32 st.end();
33 });
34
35 t.test('ARIA', (st) => {
36 st.equal(
37 isDisabledElement([
38 JSXAttributeMock('aria-disabled', 'true'),
39 ]),
40 true,
41 'does not identify ARIA disabled elements',
42 );
43
44 st.equal(
45 isDisabledElement([
46 JSXAttributeMock('aria-disabled', true),
47 ]),
48 true,
49 'does not identify ARIA disabled elements',
50 );
51
52 st.equal(
53 isDisabledElement([
54 JSXAttributeMock('aria-disabled', 'false'),
55 ]),
56 false,
57 'does not identify ARIA disabled elements',
58 );
59
60 st.equal(
61 isDisabledElement([
62 JSXAttributeMock('aria-disabled', false),
63 ]),
64 false,
65 'does not identify ARIA disabled elements',
66 );
67
68 st.equal(
69 isDisabledElement([
70 JSXAttributeMock('aria-disabled', null),
71 ]),
72 false,
73 'does not identify ARIA disabled elements with null as the value',
74 );
75
76 st.equal(
77 isDisabledElement([
78 JSXAttributeMock('aria-disabled', undefined),
79 ]),
80 false,
81 'does not identify ARIA disabled elements with undefined as the value',
82 );
83
84 st.end();
85 });
86
87 t.end();
88});
Note: See TracBrowser for help on using the repository browser.