/**
 * MainnetTetherAdmin Component Tests
 */

import { render, screen } from '@testing-library/react'
import { describe, it, expect, vi } from 'vitest'
import { WagmiProvider } from 'wagmi'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { config } from '../../../config/wagmi'
import MainnetTetherAdmin from '../../../components/admin/MainnetTetherAdmin'

// Mock AdminContext
vi.mock('../../../contexts/AdminContext', () => ({
  useAdmin: () => ({
    addAuditLog: vi.fn(),
  }),
}))

// Mock wagmi hooks
vi.mock('wagmi', async () => {
  const actual = await vi.importActual('wagmi')
  return {
    ...actual,
    useAccount: () => ({
      address: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
      isConnected: true,
    }),
    useReadContract: () => ({
      data: false,
      refetch: vi.fn(),
    }),
    useWriteContract: () => ({
      writeContract: vi.fn(),
    }),
  }
})

const queryClient = new QueryClient({
  defaultOptions: {
    queries: {
      retry: false,
    },
  },
})

describe('MainnetTetherAdmin', () => {
  it('should render the component', () => {
    render(
      <WagmiProvider config={config}>
        <QueryClientProvider client={queryClient}>
          <MainnetTetherAdmin />
        </QueryClientProvider>
      </WagmiProvider>
    )

    expect(screen.getByText(/Mainnet Tether/i)).toBeInTheDocument()
  })

  it('should display contract address', () => {
    render(
      <WagmiProvider config={config}>
        <QueryClientProvider client={queryClient}>
          <MainnetTetherAdmin />
        </QueryClientProvider>
      </WagmiProvider>
    )

    expect(screen.getByText(/0x15DF1D5BFDD8Aa4b380445D4e3E9B38d34283619/i)).toBeInTheDocument()
  })
})
