docbrown/app/javascript/listings/__tests__/ClearQueryButton.test.jsx
Nick Taylor 653ec12300
Upgrade to Preact 10.4.4 (#8739)
Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2020-06-18 10:07:17 -04:00

23 lines
723 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { h } from 'preact';
import { render } from '@testing-library/preact';
import { axe } from 'jest-axe';
import ClearQueryButton from '../components/ClearQueryButton';
describe('<ClearQueryButton />', () => {
it('has no a11y violations', async () => {
const { container } = render(<ClearQueryButton onClick={jest.fn()} />);
const results = await axe(container);
expect(results).toHaveNoViolations();
});
it('should fire a click event when pressed', () => {
const onClickHandler = jest.fn();
const { getByText } = render(<ClearQueryButton onClick={onClickHandler} />);
const button = getByText('×');
button.click();
expect(onClickHandler).toHaveBeenCalledTimes(1);
});
});