mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-23 22:27:34 -05:00
6c1eb021ba
* feat: use warning codes for deprecation warnings * Update logger.spec.ts * Update package.json
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
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();
|
|
});
|
|
});
|