import { render, screen, fireEvent } from '@testing-library/react';
import { describe, it, expect, vi } from 'vitest';
import { EmptyState } from './empty-state';
import { Music } from 'lucide-react';
describe('EmptyState Component', () => {
it('renders empty state with title and description', () => {
render(
,
);
expect(screen.getByText('No tracks found')).toBeInTheDocument();
expect(
screen.getByText("You haven't uploaded any tracks yet."),
).toBeInTheDocument();
});
it('renders with icon', () => {
render(
}
/>,
);
expect(screen.getByTestId('music-icon')).toBeInTheDocument();
});
it('renders with action button', () => {
const handleAction = vi.fn();
render(
,
);
const button = screen.getByText('Add Item');
expect(button).toBeInTheDocument();
fireEvent.click(button);
expect(handleAction).toHaveBeenCalledTimes(1);
});
it('does not render action button when action is not provided', () => {
render();
const button = screen.queryByText('Add Item');
expect(button).not.toBeInTheDocument();
});
it('applies custom className', () => {
render(
,
);
const emptyState = screen.getByText('Empty').closest('.custom-empty-state');
expect(emptyState).toBeInTheDocument();
});
it('renders without description', () => {
render();
expect(screen.getByText('Empty')).toBeInTheDocument();
});
});