2021-12-02 20:25:31 +08:00
|
|
|
import React from 'react';
|
|
|
|
import { axe } from 'jest-axe';
|
2022-04-15 23:33:10 +08:00
|
|
|
import { render } from '@testing-library/react';
|
2021-12-02 20:25:31 +08:00
|
|
|
|
|
|
|
// eslint-disable-next-line jest/no-export
|
|
|
|
export default function accessibilityTest(Component: React.ComponentType) {
|
|
|
|
describe(`accessibility`, () => {
|
|
|
|
it(`component does not have any violations`, async () => {
|
|
|
|
jest.useRealTimers();
|
2022-04-15 23:33:10 +08:00
|
|
|
const { container } = render(<Component />);
|
|
|
|
const results = await axe(container);
|
2021-12-02 20:25:31 +08:00
|
|
|
expect(results).toHaveNoViolations();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|