source: frontend/node_modules/eslint-plugin-jsx-a11y/__tests__/src/rules/scope-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.5 KB
Line 
1/**
2 * @fileoverview Enforce scope prop is only used on <th> elements.
3 * @author Ethan Cohen
4 */
5
6// -----------------------------------------------------------------------------
7// Requirements
8// -----------------------------------------------------------------------------
9
10import { RuleTester } from 'eslint';
11import parserOptionsMapper from '../../__util__/parserOptionsMapper';
12import parsers from '../../__util__/helpers/parsers';
13import rule from '../../../src/rules/scope';
14
15// -----------------------------------------------------------------------------
16// Tests
17// -----------------------------------------------------------------------------
18
19const ruleTester = new RuleTester();
20
21const expectedError = {
22 message: 'The scope prop can only be used on <th> elements.',
23 type: 'JSXAttribute',
24};
25
26const componentsSettings = {
27 'jsx-a11y': {
28 components: {
29 Foo: 'div',
30 TableHeader: 'th',
31 },
32 },
33};
34
35ruleTester.run('scope', rule, {
36 valid: parsers.all([].concat(
37 { code: '<div />;' },
38 { code: '<div foo />;' },
39 { code: '<th scope />' },
40 { code: '<th scope="row" />' },
41 { code: '<th scope={foo} />' },
42 { code: '<th scope={"col"} {...props} />' },
43 { code: '<Foo scope="bar" {...props} />' },
44 { code: '<TableHeader scope="row" />', settings: componentsSettings },
45 )).map(parserOptionsMapper),
46 invalid: parsers.all([].concat(
47 { code: '<div scope />', errors: [expectedError] },
48 { code: '<Foo scope="bar" />', settings: componentsSettings, errors: [expectedError] },
49 )).map(parserOptionsMapper),
50});
Note: See TracBrowser for help on using the repository browser.