import { describe, it, expect, vi, beforeEach } from 'vitest';
import { apiService } from '@/services/api';

// Mock axios
vi.mock('axios', () => ({
  default: {
    create: vi.fn(() => ({
      interceptors: {
        request: { use: vi.fn() },
        response: { use: vi.fn() },
      },
      get: vi.fn(),
      post: vi.fn(),
      put: vi.fn(),
      delete: vi.fn(),
    })),
    post: vi.fn(),
  },
}));

describe('API Service', () => {
  beforeEach(() => {
    vi.clearAllMocks();
  });

  it('should be defined', () => {
    expect(apiService).toBeDefined();
  });

  it('should have correct base URL', () => {
    expect(apiService).toBeDefined();
  });

  it('should handle authentication methods', () => {
    expect(typeof apiService.login).toBe('function');
    expect(typeof apiService.register).toBe('function');
    expect(typeof apiService.logout).toBe('function');
    expect(typeof apiService.getCurrentUser).toBe('function');
  });

  it('should handle user methods', () => {
    expect(typeof apiService.getUsers).toBe('function');
    expect(typeof apiService.getUser).toBe('function');
    expect(typeof apiService.updateUser).toBe('function');
  });

  it('should handle library methods', () => {
    expect(typeof apiService.getLibraryItems).toBe('function');
    expect(typeof apiService.uploadFile).toBe('function');
    expect(typeof apiService.toggleFavorite).toBe('function');
  });

  it('should handle chat methods', () => {
    expect(typeof apiService.getMessages).toBe('function');
    expect(typeof apiService.sendMessage).toBe('function');
    expect(typeof apiService.getConversations).toBe('function');
    expect(typeof apiService.createConversation).toBe('function');
  });
});
