import { describe, it, expect } from 'vitest';
import { render, screen } from '@dwellops/test-utils';
import { PageHeader } from './PageHeader';

describe('PageHeader', () => {
    it('renders the title', () => {
        render(<PageHeader title="Dashboard" />);
        expect(screen.getByRole('heading', { name: 'Dashboard', level: 1 })).toBeDefined();
    });

    it('renders the subtitle when provided', () => {
        render(<PageHeader title="Dashboard" subtitle="Sunrise Ridge HOA" />);
        expect(screen.getByText('Sunrise Ridge HOA')).toBeDefined();
    });

    it('does not render subtitle when omitted', () => {
        render(<PageHeader title="Dashboard" />);
        expect(screen.queryByText('Sunrise Ridge HOA')).toBeNull();
    });

    it('renders actions slot', () => {
        render(<PageHeader title="Units" actions={<button>Add unit</button>} />);
        expect(screen.getByRole('button', { name: 'Add unit' })).toBeDefined();
    });
});
