mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-10 23:51:59 +03:00
Adds a test file `src/logger.test.ts` to verify that `logger.info`, `logger.warn`, and `logger.error` correctly call the underlying console methods with the passed arguments. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
30 lines
1,007 B
TypeScript
30 lines
1,007 B
TypeScript
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
import { logger } from './logger';
|
|
|
|
describe('logger', () => {
|
|
beforeEach(() => {
|
|
vi.spyOn(console, 'info').mockImplementation(() => {});
|
|
vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
});
|
|
|
|
afterEach(() => {
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
it('should call console.info with correct arguments', () => {
|
|
logger.info('test info', { key: 'value' });
|
|
expect(console.info).toHaveBeenCalledWith('test info', { key: 'value' });
|
|
});
|
|
|
|
it('should call console.warn with correct arguments', () => {
|
|
logger.warn('test warn', 42);
|
|
expect(console.warn).toHaveBeenCalledWith('test warn', 42);
|
|
});
|
|
|
|
it('should call console.error with correct arguments', () => {
|
|
const error = new Error('test error');
|
|
logger.error('test error message', error);
|
|
expect(console.error).toHaveBeenCalledWith('test error message', error);
|
|
});
|
|
});
|