Permalink
Cannot retrieve contributors at this time
54 lines (47 sloc)
1.93 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/eslint-plugin-jsx-a11y/__tests__/src/rules/iframe-has-title-test.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @fileoverview Enforce iframe elements have a title attribute. | |
* @author Ethan Cohen | |
*/ | |
// ----------------------------------------------------------------------------- | |
// Requirements | |
// ----------------------------------------------------------------------------- | |
import { RuleTester } from 'eslint'; | |
import parserOptionsMapper from '../../__util__/parserOptionsMapper'; | |
import rule from '../../../src/rules/iframe-has-title'; | |
// ----------------------------------------------------------------------------- | |
// Tests | |
// ----------------------------------------------------------------------------- | |
const ruleTester = new RuleTester(); | |
const expectedError = { | |
message: '<iframe> elements must have a unique title property.', | |
type: 'JSXOpeningElement', | |
}; | |
const componentsSettings = { | |
'jsx-a11y': { | |
components: { | |
FooComponent: 'iframe', | |
}, | |
}, | |
}; | |
ruleTester.run('html-has-lang', rule, { | |
valid: [ | |
{ code: '<div />;' }, | |
{ code: '<iframe title="Unique title" />' }, | |
{ code: '<iframe title={foo} />' }, | |
{ code: '<FooComponent />' }, | |
{ code: '<FooComponent title="Unique title" />', settings: componentsSettings }, | |
].map(parserOptionsMapper), | |
invalid: [ | |
{ code: '<iframe />', errors: [expectedError] }, | |
{ code: '<iframe {...props} />', errors: [expectedError] }, | |
{ code: '<iframe title={undefined} />', errors: [expectedError] }, | |
{ code: '<iframe title="" />', errors: [expectedError] }, | |
{ code: '<iframe title={false} />', errors: [expectedError] }, | |
{ code: '<iframe title={true} />', errors: [expectedError] }, | |
{ code: "<iframe title={''} />", errors: [expectedError] }, | |
{ code: '<iframe title={``} />', errors: [expectedError] }, | |
{ code: '<iframe title={""} />', errors: [expectedError] }, | |
{ code: '<iframe title={42} />', errors: [expectedError] }, | |
{ code: '<FooComponent />', errors: [expectedError], settings: componentsSettings }, | |
].map(parserOptionsMapper), | |
}); |