import { describe, it, expect, afterEach } from 'vitest';
import { render, screen, cleanup } from '@testing-library/svelte';
import SearchResultsSkeleton from './SearchResultsSkeleton.svelte';

afterEach(() => cleanup());

describe('SearchResultsSkeleton', () => {
    it('renders the requested number of row placeholders', () => {
        render(SearchResultsSkeleton, { props: { count: 3, testid: 'sk' } });
        expect(screen.getByTestId('sk').querySelectorAll('.row').length).toBe(3);
    });

    it('defaults to 6 rows', () => {
        render(SearchResultsSkeleton, { props: { testid: 'sk' } });
        expect(screen.getByTestId('sk').querySelectorAll('.row').length).toBe(6);
    });

    it('is decorative (aria-hidden)', () => {
        render(SearchResultsSkeleton, { props: { testid: 'sk' } });
        expect(screen.getByTestId('sk').getAttribute('aria-hidden')).toBe('true');
    });
});
