This commit is contained in:
28
tests/components/Form.test.tsx
Normal file
28
tests/components/Form.test.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { Form } from '../../src/components/Form';
|
||||
|
||||
describe('Form', () => {
|
||||
it('renders title, title actions and children', () => {
|
||||
render(
|
||||
<Form title="User Details" titleBarRight={<button type="button">Action</button>}>
|
||||
<div>Form child</div>
|
||||
</Form>,
|
||||
);
|
||||
|
||||
expect(screen.getByText('User Details')).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: 'Action' })).toBeInTheDocument();
|
||||
expect(screen.getByText('Form child')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('supports custom class names and optional title actions', () => {
|
||||
const { container } = render(
|
||||
<Form title="No Actions" className="form-custom">
|
||||
<div>Child</div>
|
||||
</Form>,
|
||||
);
|
||||
|
||||
expect(container.firstElementChild).toHaveClass('form-custom');
|
||||
expect(screen.queryByRole('button')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user