-
-
Notifications
You must be signed in to change notification settings - Fork 636
/
Copy pathno-disabled-test.js
53 lines (47 loc) · 1.94 KB
/
no-disabled-test.js
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
/* eslint-env jest */
/**
* @fileoverview Enforce disabled prop is not used.
* @author Courtney Nguyen <@courtyenn>
*/
// -----------------------------------------------------------------------------
// Requirements
// -----------------------------------------------------------------------------
import { RuleTester } from 'eslint';
import rule from '../../../src/rules/no-disabled';
import parserOptionsMapper from '../../__util__/parserOptionsMapper';
// -----------------------------------------------------------------------------
// Tests
// -----------------------------------------------------------------------------
const ruleTester = new RuleTester();
const expectedWarning = {
message: 'The disabled prop removes the element from being detected by screen readers.',
type: 'JSXAttribute',
};
ruleTester.run('no-disabled', rule, {
valid: [
{ code: '<div />' },
{ code: '<div disabled />' },
{ code: '<input />' },
{ code: '<button />' },
{ code: '<select />' },
{ code: '<textarea />' },
{ code: '<option />' },
{ code: '<command />' },
{ code: '<fieldset />' },
{ code: '<keygen />' },
{ code: '<optgroup />' },
].map(parserOptionsMapper),
invalid: [
{ code: '<input disabled />', errors: [expectedWarning] },
{ code: '<input disabled="true" />', errors: [expectedWarning] },
{ code: '<input disabled="false" />', errors: [expectedWarning] },
{ code: '<button disabled />', errors: [expectedWarning] },
{ code: '<select disabled />', errors: [expectedWarning] },
{ code: '<textarea disabled />', errors: [expectedWarning] },
{ code: '<option disabled />', errors: [expectedWarning] },
{ code: '<command disabled />', errors: [expectedWarning] },
{ code: '<fieldset disabled />', errors: [expectedWarning] },
{ code: '<keygen disabled />', errors: [expectedWarning] },
{ code: '<optgroup disabled />', errors: [expectedWarning] },
].map(parserOptionsMapper),
});