/** * Tests for Logger Utility * FE-TEST-004: Test logger utility functions */ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { logger } from './logger'; describe('logger utilities', () => { let consoleDebugSpy: ReturnType; let consoleInfoSpy: ReturnType; let consoleWarnSpy: ReturnType; let consoleErrorSpy: ReturnType; beforeEach(() => { consoleDebugSpy = vi.spyOn(console, 'debug').mockImplementation(() => {}); consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => {}); consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}); consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {}); }); afterEach(() => { vi.restoreAllMocks(); }); describe('logger.debug', () => { it('should log in development mode', () => { // In test environment, DEV is typically true logger.debug('test message'); // Just verify it doesn't throw - actual behavior depends on import.meta.env.DEV expect(typeof logger.debug).toBe('function'); }); }); describe('logger.info', () => { it('should log in development mode', () => { // In test environment, DEV is typically true logger.info('test message'); // Just verify it doesn't throw - actual behavior depends on import.meta.env.DEV expect(typeof logger.info).toBe('function'); }); }); describe('logger.warn', () => { it('should always log warnings', () => { logger.warn('test warning'); expect(consoleWarnSpy).toHaveBeenCalledWith('[WARN]', 'test warning'); }); }); describe('logger.error', () => { it('should always log errors', () => { logger.error('test error'); expect(consoleErrorSpy).toHaveBeenCalledWith('[ERROR]', 'test error'); }); }); });