Files
frontend-app-ora-grading/src/components/FilePreview/FileInfo.test.jsx
Diana Villalvazo a579455e58 test: Remove unwanted mocks, unmocks and deprecate react-unit-test-utils package (#465)
* test: remove last snapshot

* test: remove unwanted mocks, remove unmocks, refactor renderWithIntl

* test: refactor renderWithIntl with small improvements

* test: remove react-unit-test-utils

* test: change fireEvent for userEvent
2025-09-05 12:34:28 -04:00

30 lines
1014 B
JavaScript

import { screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { renderWithIntl } from '../../testUtils';
import FileInfo from './FileInfo';
import messages from './messages';
describe('FileInfo component', () => {
const children = (<h1>some Children</h1>);
const props = { onClick: jest.fn().mockName('this.props.onClick') };
beforeEach(() => {
jest.clearAllMocks();
});
describe('Component rendering', () => {
it('renders the FileInfo button with correct text', () => {
renderWithIntl(<FileInfo {...props}>{children}</FileInfo>);
expect(screen.getByText(messages.fileInfo.defaultMessage)).toBeInTheDocument();
});
it('calls onClick when button is clicked', async () => {
renderWithIntl(<FileInfo {...props}>{children}</FileInfo>);
const user = userEvent.setup();
await user.click(screen.getByText(messages.fileInfo.defaultMessage));
expect(props.onClick).toHaveBeenCalledTimes(1);
});
});
});