import { describe, it, expect, vi, beforeEach } from 'vitest';

vi.mock('mysql2/promise', () => ({
  default: {
    createPool: vi.fn(() => ({
      execute: vi.fn(),
      end: vi.fn(),
    })),
  },
}));

describe('database pool', () => {
  beforeEach(() => {
    vi.resetModules();
  });

  it('should create pool with correct config', async () => {
    const mysql = await import('mysql2/promise');
    const { initializePool } = await import('../../../src/database/pool.js');

    initializePool();

    expect(mysql.default.createPool).toHaveBeenCalledWith(
      expect.objectContaining({
        waitForConnections: true,
        connectionLimit: 20,
      })
    );
  });
});
