docbrown/app/javascript/chat/__tests__/reportAbuse.test.jsx
Katie Davis 76453b41fb
Updates ESLint rules to error on default imports (#12512)
* add rule

* add named imports

* more missed files

* so many files
2021-02-02 10:24:03 -05:00

44 lines
1.2 KiB
JavaScript

import { h } from 'preact';
import { render } from '@testing-library/preact';
import { axe } from 'jest-axe';
import { ReportAbuse } from '../ReportAbuse';
describe('<ReportAbuse />', () => {
it('should have no a11y violations', async () => {
const { container } = render(
<ReportAbuse
data={{
message: 'HI',
user_id: 1,
}}
/>,
);
const results = await axe(container);
expect(results).toHaveNoViolations();
});
it('should render the component', () => {
const { getByText, getByLabelText } = render(
<ReportAbuse data={{ message: 'HI', user_id: 1 }} />,
);
expect(getByText('Report Abuse')).toBeDefined();
const vulgarInput = getByLabelText('Rude or vulgar');
expect(vulgarInput.value).toEqual('rude or vulgar');
const harassmentInput = getByLabelText('Harassment or hate speech');
expect(harassmentInput.value).toEqual('harassment');
const listingsInput = getByLabelText(
'Inappropriate listings message/category',
);
expect(listingsInput.value).toEqual('listings');
const spamInput = getByLabelText('Spam or copyright issue');
expect(spamInput.value).toEqual('spam');
expect(getByText('Report Message')).toBeDefined();
});
});