import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import { Button } from './index';

describe('Button', () => {
  it('renders correctly', () => {
    render(<Button>Hey</Button>);

    expect(screen.getByText(/Hey/i)).toBeInTheDocument();
  });

  it('fires the onClick event', async () => {
    const onClick = vi.fn();

    render(<Button onClick={onClick}>Hey</Button>);

    await userEvent.click(screen.getByRole('button'));

    expect(onClick).toBeCalledTimes(1);
  });
});
