2025-12-25 16:09:51 +00:00
|
|
|
/**
|
|
|
|
|
* 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', () => {
|
chore(refactor/sumi-migration): commit pending changes — tests, stream server, dist_verification
- apps/web: test updates (Vitest/setup), playbackAnalyticsService, TrackGrid, serviceErrorHandler
- veza-common: logging, metrics, traits, validation, random
- veza-stream-server: audio pipeline, codecs, cache, monitoring, routes
- apps/web/dist_verification: refresh build assets (content-hashed filenames)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-13 18:39:18 +00:00
|
|
|
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
2025-12-25 16:09:51 +00:00
|
|
|
logger.warn('test warning');
|
chore(refactor/sumi-migration): commit pending changes — tests, stream server, dist_verification
- apps/web: test updates (Vitest/setup), playbackAnalyticsService, TrackGrid, serviceErrorHandler
- veza-common: logging, metrics, traits, validation, random
- veza-stream-server: audio pipeline, codecs, cache, monitoring, routes
- apps/web/dist_verification: refresh build assets (content-hashed filenames)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-13 18:39:18 +00:00
|
|
|
// In dev mode, logger uses console.log with formatted prefix
|
|
|
|
|
expect(consoleLogSpy).toHaveBeenCalledWith(
|
|
|
|
|
expect.stringContaining('[WARN] test warning'),
|
|
|
|
|
);
|
|
|
|
|
consoleLogSpy.mockRestore();
|
2025-12-25 16:09:51 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('logger.error', () => {
|
|
|
|
|
it('should always log errors', () => {
|
chore(refactor/sumi-migration): commit pending changes — tests, stream server, dist_verification
- apps/web: test updates (Vitest/setup), playbackAnalyticsService, TrackGrid, serviceErrorHandler
- veza-common: logging, metrics, traits, validation, random
- veza-stream-server: audio pipeline, codecs, cache, monitoring, routes
- apps/web/dist_verification: refresh build assets (content-hashed filenames)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-13 18:39:18 +00:00
|
|
|
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
2025-12-25 16:09:51 +00:00
|
|
|
logger.error('test error');
|
chore(refactor/sumi-migration): commit pending changes — tests, stream server, dist_verification
- apps/web: test updates (Vitest/setup), playbackAnalyticsService, TrackGrid, serviceErrorHandler
- veza-common: logging, metrics, traits, validation, random
- veza-stream-server: audio pipeline, codecs, cache, monitoring, routes
- apps/web/dist_verification: refresh build assets (content-hashed filenames)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-13 18:39:18 +00:00
|
|
|
// In dev mode, logger uses console.log with formatted prefix
|
|
|
|
|
expect(consoleLogSpy).toHaveBeenCalledWith(
|
|
|
|
|
expect.stringContaining('[ERROR] test error'),
|
|
|
|
|
);
|
|
|
|
|
consoleLogSpy.mockRestore();
|
2025-12-25 16:09:51 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|