// src/services/logger.server.test.ts
import { describe, it, expect, vi, beforeEach } from 'vitest';

// Mock pino before importing the logger
const pinoMock = vi.fn(() => ({
  info: vi.fn(),
  warn: vi.fn(),
  error: vi.fn(),
  debug: vi.fn(),
}));
vi.mock('pino', () => ({ default: pinoMock }));

describe('Server Logger', () => {
  beforeEach(() => {
    // Reset modules to ensure process.env changes are applied to new module instances
    vi.resetModules();
    vi.clearAllMocks();
  });

  it('should initialize pino with the correct level for production', async () => {
    process.env.NODE_ENV = 'production';
    await import('./logger.server');
    expect(pinoMock).toHaveBeenCalledWith(expect.objectContaining({ level: 'info' }));
  });

  it('should initialize pino with pretty-print transport for development', async () => {
    process.env.NODE_ENV = 'development';
    await import('./logger.server');
    expect(pinoMock).toHaveBeenCalledWith(expect.objectContaining({ transport: expect.any(Object) }));
  });
});