import { renderHook, waitFor } from '@testing-library/react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { useFuelGrades } from '../../src/features/fuel-logs/hooks/useFuelGrades';
import * as api from '../../src/features/fuel-logs/api/fuel-logs.api';

const qc = new QueryClient();

jest.spyOn(api.fuelLogsApi, 'getFuelGrades').mockResolvedValue([
  { value: '87', label: '87 (Regular)' },
  { value: '91', label: '91 (Premium)' },
]);

describe('useFuelGrades', () => {
  it('returns grades for gasoline', async () => {
    const wrapper = ({ children }: any) => <QueryClientProvider client={qc}>{children}</QueryClientProvider>;
    const { result } = renderHook(() => useFuelGrades('gasoline' as any), { wrapper });
    await waitFor(() => expect(result.current.fuelGrades.length).toBeGreaterThan(0));
  });
});

