/**
 * Mock server using Vitest mocks instead of MSW.
 * This provides a simpler setup that works with all Node versions.
 */

import { vi } from 'vitest';
import { mockUser, mockUnverifiedUser, mockItem, mockRental } from './handlers';

// Re-export mock data
export { mockUser, mockUnverifiedUser, mockItem, mockRental };

// Mock server interface for compatibility with setup
export const server = {
  listen: vi.fn(),
  resetHandlers: vi.fn(),
  close: vi.fn(),
  use: vi.fn(),
};

// Setup axios mock
vi.mock('axios', () => {
  const mockAxiosInstance = {
    get: vi.fn(),
    post: vi.fn(),
    put: vi.fn(),
    delete: vi.fn(),
    patch: vi.fn(),
    interceptors: {
      request: { use: vi.fn(), eject: vi.fn() },
      response: { use: vi.fn(), eject: vi.fn() },
    },
    defaults: {
      headers: {
        common: {},
      },
    },
  };

  return {
    create: vi.fn(() => mockAxiosInstance),
    default: mockAxiosInstance,
    ...mockAxiosInstance,
  };
});
