import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom'; import userEvent from '@testing-library/user-event'; import { SendButton } from './SendButton'; import { TooltipProps } from '@patternfly/react-core'; const renderSend = (props?: { [key: string]: string | boolean | Omit }) => { const spy = jest.fn(); render(); }; describe('Send button', () => { it('should render button correctly', () => { renderSend(); expect(screen.getByRole('button', { name: 'Send' })).toBeTruthy(); }); it('should handle onClick correctly', async () => { const spy = jest.fn(); render(); await userEvent.click(screen.getByRole('button', { name: 'Send' })); expect(screen.getByRole('tooltip', { name: 'Send' })).toBeTruthy(); expect(spy).toHaveBeenCalledTimes(1); }); it('should handle custom tooltip correctly', async () => { render(); await userEvent.click(screen.getByRole('button', { name: 'Send' })); expect(screen.getByRole('tooltip', { name: 'Test' })).toBeTruthy(); }); it('should handle className prop', () => { renderSend({ className: 'test' }); expect(screen.getByRole('button', { name: 'Send' })).toHaveClass('test'); }); it('should handle spread props, including aria-label', () => { renderSend({ 'aria-label': 'test' }); expect(screen.getByRole('button', { name: 'test' })); }); it('should handle tooltipProps prop', async () => { renderSend({ tooltipProps: { id: 'test' } }); await userEvent.click(screen.getByRole('button', { name: 'Send' })); expect(screen.getByRole('tooltip', { name: 'Send' })).toHaveAttribute('id', 'test'); }); it('should handle isCompact', () => { renderSend({ 'data-testid': 'button', isCompact: true }); expect(screen.getByTestId('button')).toHaveClass('pf-m-compact'); }); });