docbrown/app/javascript/listings/__tests__/NextPageButton.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

34 lines
957 B
JavaScript

import { h } from 'preact';
import { render } from '@testing-library/preact';
import { axe } from 'jest-axe';
import { NextPageButton } from '../components/NextPageButton';
describe('<NextPageButton />', () => {
const defaultProps = {
onClick: () => {
return 'onClick';
},
};
it('should have no a11y violations', async () => {
const { container } = render(<NextPageButton {...defaultProps} />);
const results = await axe(container);
expect(results).toHaveNoViolations();
});
it('should show a button', () => {
const { queryByText } = render(<NextPageButton {...defaultProps} />);
expect(queryByText(/load more/i)).toBeDefined();
});
it('should call the onclick handler', () => {
const onClick = jest.fn();
const { getByText } = render(<NextPageButton onClick={onClick} />);
const button = getByText(/load more/i);
button.click();
expect(onClick).toHaveBeenCalledTimes(1);
});
});