import { render, screen } from '@testing-library/react'
import { describe, it, expect, vi } from 'vitest'
import { BrowserRouter } from 'react-router-dom'
import App from './App'

vi.mock('./context/AuthContext', async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    AuthProvider: ({ children }) => children,
    useAuth: () => ({ user: null, loading: false })
  }
})

vi.mock('./context/SocketContext', async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    SocketProvider: ({ children }) => children,
    useSocket: () => ({ unreadCount: 0, notifications: [], joinBooking: vi.fn(), sendMessage: vi.fn(), markRead: vi.fn(), markAllRead: vi.fn() })
  }
})

const renderWithProviders = (ui) => {
  return render(
    <BrowserRouter>
      <App />
    </BrowserRouter>
  )
}

describe('App', () => {
  it('renders without crashing', () => {
    renderWithProviders(<App />)
    expect(screen.getAllByText('Handyman').length).toBeGreaterThan(0)
  })
})