2022-06-04 20:02:20 +03:00
|
|
|
import { fireEvent, render, screen } from '@testing-library/react';
|
2020-03-15 13:59:07 +03:00
|
|
|
import { ServerForm } from '../../../src/servers/helpers/ServerForm';
|
2023-09-30 11:45:52 +03:00
|
|
|
import { checkAccessibility } from '../../__helpers__/accessibility';
|
2020-03-15 13:59:07 +03:00
|
|
|
|
|
|
|
describe('<ServerForm />', () => {
|
2023-05-27 12:57:26 +03:00
|
|
|
const onSubmit = vi.fn();
|
2022-06-04 20:02:20 +03:00
|
|
|
const setUp = () => render(<ServerForm onSubmit={onSubmit}>Something</ServerForm>);
|
2020-03-15 13:59:07 +03:00
|
|
|
|
2023-09-30 11:45:52 +03:00
|
|
|
it('passes a11y checks', () => checkAccessibility(setUp()));
|
|
|
|
|
2020-03-15 13:59:07 +03:00
|
|
|
it('renders components', () => {
|
2022-06-04 20:02:20 +03:00
|
|
|
setUp();
|
2020-03-15 13:59:07 +03:00
|
|
|
|
2022-06-04 20:02:20 +03:00
|
|
|
expect(screen.getAllByRole('textbox')).toHaveLength(3);
|
|
|
|
expect(screen.getByText('Something')).toBeInTheDocument();
|
|
|
|
});
|
2020-03-15 13:59:07 +03:00
|
|
|
|
2022-06-04 20:02:20 +03:00
|
|
|
it('invokes submit callback when submit event is triggered', async () => {
|
|
|
|
setUp();
|
2020-03-15 13:59:07 +03:00
|
|
|
|
2022-06-04 20:02:20 +03:00
|
|
|
expect(onSubmit).not.toHaveBeenCalled();
|
2023-05-27 12:57:26 +03:00
|
|
|
fireEvent.submit(screen.getByRole('form'), { preventDefault: vi.fn() });
|
2020-03-15 13:59:07 +03:00
|
|
|
expect(onSubmit).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
});
|