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

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: jest.fn(),
  resetHandlers: jest.fn(),
  close: jest.fn(),
  use: jest.fn(),
};

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

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