docbrown/app/javascript/listings/__tests__/ContactViaConnect.test.jsx
ludwiczakpawel 90d04a73db
Crayonsification of Listings form (#10429)
* i dont know how to test

* fix i guess

* layout update

* layout updates

* edit

* edit listing

* fix

* tags field

* specs|

* Update app/javascript/listings/__tests__/ContactViaConnect.test.jsx

Co-authored-by: Fernando Valverde <fernando@visualcosita.com>

Co-authored-by: Fernando Valverde <fernando@visualcosita.com>
2020-09-30 09:14:48 +02:00

38 lines
1.1 KiB
JavaScript

import { h } from 'preact';
import { render, fireEvent } from '@testing-library/preact';
import { axe } from 'jest-axe';
import ContactViaConnect from '../components/ContactViaConnect';
describe('<ContactViaConnect />', () => {
it('should have no a11y violations', async () => {
const onChange = jest.fn;
const { container } = render(
<ContactViaConnect onChange={onChange} checked />,
);
const results = await axe(container);
expect(results).toHaveNoViolations();
});
it('should render a checked check box opting in to open DMs', () => {
const onChange = jest.fn();
const { getByText } = render(
<ContactViaConnect onChange={onChange} checked />,
);
expect(getByText('Allow Users to message me via Connect.')).toBeDefined();
});
it('should fire a change event when clicking the checkbox', () => {
const onChange = jest.fn();
const { getByText } = render(
<ContactViaConnect onChange={onChange} checked />,
);
const checkbox = getByText('Allow Users to message me via Connect.');
fireEvent.click(checkbox);
expect(onChange).toHaveBeenCalledTimes(1);
});
});