Permalink
Cannot retrieve contributors at this time
70 lines (69 sloc)
2.51 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/util/isNonInteractiveElement-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
import expect from 'expect'; | |
import { elementType } from 'jsx-ast-utils'; | |
import isNonInteractiveElement from '../../../src/util/isNonInteractiveElement'; | |
import { | |
genElementSymbol, | |
genIndeterminantInteractiveElements, | |
genInteractiveElements, | |
genInteractiveRoleElements, | |
genNonInteractiveElements, | |
genNonInteractiveRoleElements, | |
} from '../../../__mocks__/genInteractives'; | |
describe('isNonInteractiveElement', () => { | |
describe('JSX Components (no tagName)', () => { | |
it('should identify them as interactive elements', () => { | |
expect(isNonInteractiveElement(undefined, [])) | |
.toBe(false); | |
}); | |
}); | |
describe('non-interactive elements', () => { | |
genNonInteractiveElements().forEach(({ openingElement }) => { | |
it(`should identify \`${genElementSymbol(openingElement)}\` as a non-interactive element`, () => { | |
expect(isNonInteractiveElement( | |
elementType(openingElement), | |
openingElement.attributes, | |
)).toBe(true); | |
}); | |
}); | |
}); | |
describe('non-interactive role elements', () => { | |
genNonInteractiveRoleElements().forEach(({ openingElement }) => { | |
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as a non-interactive element`, () => { | |
expect(isNonInteractiveElement( | |
elementType(openingElement), | |
openingElement.attributes, | |
)).toBe(false); | |
}); | |
}); | |
}); | |
describe('interactive elements', () => { | |
genInteractiveElements().forEach(({ openingElement }) => { | |
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as a non-interactive element`, () => { | |
expect(isNonInteractiveElement( | |
elementType(openingElement), | |
openingElement.attributes, | |
)).toBe(false); | |
}); | |
}); | |
}); | |
describe('interactive role elements', () => { | |
genInteractiveRoleElements().forEach(({ openingElement }) => { | |
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as a non-interactive element`, () => { | |
expect(isNonInteractiveElement( | |
elementType(openingElement), | |
openingElement.attributes, | |
)).toBe(false); | |
}); | |
}); | |
}); | |
describe('indeterminate elements', () => { | |
genIndeterminantInteractiveElements().forEach(({ openingElement }) => { | |
it(`should NOT identify \`${openingElement.name.name}\` as a non-interactive element`, () => { | |
expect(isNonInteractiveElement( | |
elementType(openingElement), | |
openingElement.attributes, | |
)).toBe(false); | |
}); | |
}); | |
}); | |
}); |