import { render, screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from '../card';
describe('Card', () => {
it('renders card with all sub-components', () => {
render(
Title
Description
Content
Footer
,
);
expect(screen.getByTestId('card')).toBeInTheDocument();
expect(screen.getByText('Title')).toBeInTheDocument();
expect(screen.getByText('Description')).toBeInTheDocument();
expect(screen.getByText('Content')).toBeInTheDocument();
expect(screen.getByText('Footer')).toBeInTheDocument();
});
it('applies custom className to Card', () => {
render(Content);
expect(screen.getByTestId('card')).toHaveClass('custom');
expect(screen.getByTestId('card')).toHaveClass('rounded-lg');
});
it('renders CardTitle as h3', () => {
render(My Title);
expect(screen.getByRole('heading', { level: 3 })).toHaveTextContent('My Title');
});
it('renders CardDescription as paragraph', () => {
render(My Description);
expect(screen.getByText('My Description').tagName).toBe('P');
});
});