front/__tests__/ActionButton.test.tsx
2024-10-19 08:16:51 +03:00

19 lines
620 B
TypeScript

import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import ActionButton from '../src/components/account/ActionButton.jsx';
describe('ActionButton Component', () => {
it('should render with the correct title and call the action when clicked', () => {
const mockAction = jest.fn();
const title = 'Click Me';
render(<ActionButton action={mockAction} title={title} />);
const buttonElement = screen.getByText(title);
expect(buttonElement).toBeInTheDocument();
fireEvent.click(buttonElement);
expect(mockAction).toHaveBeenCalledTimes(1);
});
});