0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/packages/logger/test/logger.spec.ts

54 lines
1.2 KiB
TypeScript
Raw Normal View History

import { warningUtils } from '@verdaccio/core';
import { logger, setup } from '../src';
const mockWarningUtils = jest.fn();
jest.mock('@verdaccio/core', () => {
const original = jest.requireActual('@verdaccio/core');
return {
warningUtils: {
...original.warningUtils,
emit: (...args) => {
mockWarningUtils(...args);
},
},
};
});
describe('logger', () => {
beforeEach(() => {
jest.clearAllMocks();
});
test.skip('should write message logger', () => {
jest.spyOn(process.stdout, 'write');
setup([
{
level: 'info',
},
]);
logger.info({ packageName: 'test' }, `publishing or updating a new version for @{packageName}`);
// FIXME: check expect
// expect(spyOn).toHaveBeenCalledTimes(2);
});
test('throw deprecation warning if multiple loggers configured', () => {
setup([
{
level: 'info',
},
{
level: 'http',
},
]);
expect(mockWarningUtils).toHaveBeenCalledWith(warningUtils.Codes.VERDEP002);
});
test('regression: do not throw deprecation warning if no logger config is provided', () => {
setup();
expect(mockWarningUtils).not.toHaveBeenCalled();
});
});