57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
/**
|
|
* 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<typeof vi.spyOn>;
|
|
let consoleInfoSpy: ReturnType<typeof vi.spyOn>;
|
|
let consoleWarnSpy: ReturnType<typeof vi.spyOn>;
|
|
let consoleErrorSpy: ReturnType<typeof vi.spyOn>;
|
|
|
|
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');
|
|
});
|
|
});
|
|
});
|