import { fireEvent, render, screen } from '@testing-library/react'; import { PrimaryButton, SecondaryButton, DisabledButton } from './Button.stories'; it('should call the onClick function when Primary button is clicked', () => { const spyHandleOnClick = jest.fn(); render(); const button = screen.getByText('Primary Button'); fireEvent.click(button); expect(button).toBeInTheDocument(); expect(spyHandleOnClick).toHaveBeenCalledTimes(1); }); it('should call the onClick function when Secondary button is clicked', () => { const spyHandleOnClick = jest.fn(); render(); const button = screen.getByText('Secondary Button'); fireEvent.click(button); expect(button).toBeInTheDocument(); expect(spyHandleOnClick).toHaveBeenCalledTimes(1); }); it('should not call the onClick function when Disabled button is clicked', () => { render(); const button = screen.getByText('Disabled Button'); expect(button).toBeInTheDocument(); expect(button).toHaveAttribute('disabled'); });