import { h } from 'preact'; import { render, fireEvent } from '@testing-library/preact'; import { axe } from 'jest-axe'; import ContactViaConnect from '../components/ContactViaConnect'; describe('', () => { it('should have no a11y violations', async () => { const onChange = jest.fn; const { container } = render( , ); 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 { queryByLabelText } = render( , ); expect( queryByLabelText( 'Allow Users to Message Me Via In-App Chat (DEV Connect)', ), ).toBeDefined(); }); it('should fire a change event when clicking the checkbox', () => { const onChange = jest.fn(); const { getByLabelText } = render( , ); const checkbox = getByLabelText( 'Allow Users to Message Me Via In-App Chat (DEV Connect)', ); fireEvent.input(checkbox, { target: { checked: true } }); expect(onChange).toHaveBeenCalledTimes(1); }); });