import React from 'react';
import { describe, it, expect, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import { GlobalSearchResultsPage } from '@/pages/GlobalSearchResults';

vi.mock('@/api/hooks', () => ({
  useGlobalSearch: () => ({
    data: [
      { id: '1', type: 'contact', name: 'TestCorp GmbH', description: 'IT company', url: '/contacts/1' },
      { id: '2', type: 'contact', name: 'Max Mustermann', description: 'CEO', url: '/contacts/2' },
    ],
    isLoading: false,
  }),
}));

describe('GlobalSearchResultsPage', () => {
  it('renders search page', () => {
    render(<MemoryRouter initialEntries={['/search?q=test']}><GlobalSearchResultsPage /></MemoryRouter>);
    expect(screen.getByTestId('global-search-page')).toBeInTheDocument();
  });

  it('renders search input field', () => {
    render(<MemoryRouter initialEntries={['/search?q=test']}><GlobalSearchResultsPage /></MemoryRouter>);
    expect(screen.getByTestId('search-input')).toBeInTheDocument();
  });
});
