codeql-action/node_modules/eslint-plugin-jsx-a11y/__tests__/src/util/getExplicitRole-test.js
2023-01-18 21:00:07 +00:00

30 lines
765 B
JavaScript

import expect from 'expect';
import getExplicitRole from '../../../src/util/getExplicitRole';
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
describe('getExplicitRole', () => {
describe('valid role', () => {
it('should return the role', () => {
expect(getExplicitRole(
'div',
[JSXAttributeMock('role', 'button')],
)).toBe('button');
});
});
describe('invalid role', () => {
it('should return null', () => {
expect(getExplicitRole(
'div',
[JSXAttributeMock('role', 'beeswax')],
)).toBeNull();
});
});
describe('no role', () => {
it('should return null', () => {
expect(getExplicitRole(
'div',
[],
)).toBeNull();
});
});
});